Google Analytics

Google Analytics Debugging

Posted at April 26, 2012 | By : | Categories : Google Analytics | 2 Comments

Let's face it: Google Analytics' documentation contains a lot of examples that work very well for simple use-cases, but advanced configurations require planning and attention to detail, and copying-and-pasting sometimes introduces problems that can affect data accuracy.

Historically, the biggest problems we find stem from configuring multiple trackers – often because some third-party script (for user surveys, etc.) is trying to track their usage, but their trackers conflict with your own. Tracker conflicts almost always relate to their handling of cookies, which domains their being written to, and what value is used for the domain hash prefix. Recent changes to GA have improved this somewhat, but problems persist in some cases.

An important aspect of debugging these kinds of problems is to find all the trackers actively running on the page. The hard part is usually in searching through all the scripts on the page, looking for _setAccount or similar. Fortunately, GA has made that somewhat easier: they've introduced a method _gat._getTrackers that exposes all current trackers.

Modern browser debuggers, in combination with these Google Analytics methods, provide a convenient way to inspect tracking problems. For example, to list current trackers by Web Property ID and tracker name, paste this code in a debugger:

var m = _gat._getTrackers(), i = m.length; while(i--) console.info(m[i]._getAccount(), m[i]._getName());

This list should provide you some insight into what trackers might be conflicting – particularly if there are some listed that you weren't previously aware of. Using either the tracker name or the WPID's listed, you can then search specifically for those trackers in Javascript on your page. (Chrome's Debugger makes it easy.)

Step-by-step screenshots for listing trackers in Google Chrome:

We'll be posting more debugging tips in the nearer future. Stay tuned!

Share

Comment

  • Michael Whitaker

    April 26, 2012 at 11:14 am

    Nice one! Note small typo in the code while(i-)  should be while(i–)  as in your screenshot.

    • Sam

      April 27, 2012 at 9:23 am

      Thanks for letting us know – updating it momentarily. Looks like the WYSIWYG editor revised my code for me. :p

Leave a Comment