Skip to content

Instantly share code, notes, and snippets.

@davemasse
Forked from davemasse-mam/analytics_debug.js
Created March 13, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemasse/5153184 to your computer and use it in GitHub Desktop.
Save davemasse/5153184 to your computer and use it in GitHub Desktop.
It can be difficult to tell what’s being tracked by Google Analytics with the delay between triggering actions in the browser and seeing those records in the Google Analytics dashboard. This is a quick and dirty way to track Google Analytics actions locally to make sure events are being triggered correctly before going to production.
// Debugging of Analytics calls via console.log
function _gaq_pop() {
var max = _gaq.length;
// Iterate only up to the current length of the object to prevent issues with _gaq.push being called while in the loop
for (var i = 0; i < max; i++) {
if (console && console.log) {
console.log(_gaq.shift());
}
}
}
setInterval(_gaq_pop, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment