Skip to content

Instantly share code, notes, and snippets.

View davemasse-mam's full-sized avatar

davemasse-mam

View GitHub Profile
@davemasse-mam
davemasse-mam / analytics_debug.js
Last active December 14, 2015 01:59
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());
}
}