Created
January 9, 2014 13:51
-
-
Save cssimsek/8334378 to your computer and use it in GitHub Desktop.
Very basic JS script to check if ga.js or analytics.js scripts (standard implementations) are present on a page
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
(function(){ | |
var myScripts = document.getElementsByTagName("script"); | |
var result = []; | |
for(var i = 0; i < myScripts.length; i += 1){ | |
if(myScripts[i].src.substr(-12, 12) === "analytics.js"){ | |
result.push(myScripts[i].baseURI + " has analytics.js installed"); | |
} | |
else if(myScripts[i].src.substr(-5, 5) === "ga.js"){ | |
result.push(myScripts[i].baseURI + " has ga.js installed"); | |
} | |
} | |
if(result.length < 1){ | |
console.log("No standard analytics tags were found"); | |
} | |
console.log(result); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment