Adam Howitt's Blog

Oct 23
2006

Google Analytics trouble

I've been helping a client setup Google Analytics, specifically adding the e-commerce tracking.  As with most analytics packages, stats are updated as part of a batch every few hours so it's tricky to troubleshoot the code when things aren't going well.

I was getting the tracking code to work, even on the SSL encrypted pages but the e-commerce tracking piece wasn't reporting any revenue.  The tracking code is offered in two flavors, either an inline chunk of script to execute or called from the page onload function.  To minimize disruption to the dsp_header.cfm in use throughout the site I thought I would add the inline code on the receipt page instead.  No dice.  Here is the problem: it fails silently on an AJAX call so I was stuck. LiveHTTPHeaders to the rescue. This neat little Firefox plugin works like Fiddler but is built into your browser.  Turn it on and each HTTP request is logged either in the sidebar or a new tab. 

With LiveHTTPHeaders turned on it became clear the inline JavaScript fragment didn't work so I moved my call to the dsp_header.cfm file with a condition based on whether you were viewing a receipt page or not.  LiveHTTPHeaders cheerfully reported that I was now sending data to Google.  All I need to do now is wait 4 hours to see if the data shows up.

Really loving Google Analytics - has anyone else used it?  How does it stack up to other analytics packages you have seen?  I love the custom funnel pages to be able to track e-commerce activity and the cross-tabbing of most data points to be able to dig in by city, country etc.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
[Add Comment] [Subscribe to Comments]
  1. I have been using it on a few sites and it has worked well. I have not gone thru the comparison of GA and Web log reports though.

  2. I'm using GA to track stats on the Duo Consulting site along side Urchin and HitBox. The numbers are all fairly similar (you're looking for trends not exacts anyway) and I really like that I don't have anyone else set up custom views for me, its all pretty easy to self-serve.

  3. When I put the GA code on a page that I use SSL on, I get a mixed error message. Is it possible to use https instead of http, or have you come up with a better option?

  4. Yes, I check the cgi.server_port variable for 443 (SSL) and set the script source accordingly: <script src="<cfif cgi.SERVER_PORT eq "443">https://ssl.google-analytics.com/urchin.js<cfelse>http://www.google-analytics.com/urchin.js</cfif>" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-xxxx-x"; urchinTracker(); </script>

  5. Nice piece of code, I've been looking for hours for this :). Did you setup your GA site profile with Https or Http? Does that matter at all?

    Also, would you mind sharing your header code related to GA e-commerce tracking?

    Thanks! Edward

  6. Thanks! Just what I needed too. I've handled this with JavaScript too, but for some reason it didn't work on the ColdFusion site I manage.

[Add Comment]