Last active
October 3, 2018 15:09
-
-
Save vensires/31ee81be5293f2ab0f92021f0d145203 to your computer and use it in GitHub Desktop.
JS script to be executed in console.log() in order to find the Google Analytics UA code of a website. The same code code be used in a bookmarklet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The following script requires jQuery to exist in the website. | |
*/ | |
(function($) { | |
if (typeof(ga) == "undefined") { | |
console.log('No Google Analytics script found'); | |
} | |
else { | |
var UAs = ga.getAll(); | |
$.each(UAs, function(key, value) { | |
console.log(value.b.data.values[':trackingId']); | |
}); | |
} | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The following script requires browser to support the forEach() callback. | |
*/ | |
(function() { | |
if (typeof(ga) == "undefined") { | |
console.log('No Google Analytics script found'); | |
} | |
else { | |
var UAs = ga.getAll(); | |
UAs.foReach(function(key, value) { | |
console.log(value.b.data.values[':trackingId']); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment