Skip to content

Instantly share code, notes, and snippets.

@apeckham
Created December 8, 2009 22:35
Show Gist options
  • Save apeckham/252058 to your computer and use it in GitHub Desktop.
Save apeckham/252058 to your computer and use it in GitHub Desktop.
var TRACK_URL = 'http://www.google-analytics.com/ga.js';
var TRACK_TRIES = 0;
function Monitor() {
if ("_gat" in window) {
window.clearInterval(Monitor.INTERVAL);
Monitor.INTERVAL = null;
var A = _gat._getTracker("UA-176427-3");
A._initData();
A._trackPageview()
} else {
TRACK_TRIES++;
if (TRACK_TRIES === 50) {
window.clearInterval(Monitor.INTERVAL);
Monitor.INTERVAL = null
}
}
}
(function Track() {
window.setTimeout(function() {
var A = document.createElement("script");
A.src = TRACK_URL;
document.body.appendChild(A);
Monitor.INTERVAL = window.setInterval(Monitor, 100)
}, 10)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment