Skip to content

Instantly share code, notes, and snippets.

@ptz0n
Last active July 1, 2018 14:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptz0n/9892262 to your computer and use it in GitHub Desktop.
Save ptz0n/9892262 to your computer and use it in GitHub Desktop.
Google Analytics - Universal or Legacy?
/**
* Check whether we have the legacy or universal lib available
*
* https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs
*
*/
if(typeof _gaq !== 'undefined') {
console.log('ga.js'); // or via GTM?
}
else if(typeof ga !== 'undefined') {
console.log('analytics.js');
}
else {
// No GA available on page :(
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment