Skip to content

Instantly share code, notes, and snippets.

@ben1one
Created October 27, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ben1one/b5121a2241824f693b167306e30b7478 to your computer and use it in GitHub Desktop.
Save ben1one/b5121a2241824f693b167306e30b7478 to your computer and use it in GitHub Desktop.
function pageTracking() {
var url = $_data.URL;
if (!url.startsWith("/")) {
url = "/" + url;
}
//console.log(url);
if (isGaLoaded()) {
var ga_url = url;
//console.log(ga_url);
//Old tracking
if ('object' === typeof _gaq) {
_gaq.push(['_trackPageview', ga_url]);
console.log("Old tracking");
}
//New tracking
if ('function' === typeof ga) {
ga('send', 'pageview', ga_url);
console.log("New tracking");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment