All Hard Coded JavaScript Files


This custom tag captures all hard coded JavaScript files that are not loaded dynamically or in a Tag Management System. The script can be used to specifically exclude a couple of domains and load all the other JavaScript files.

Under Variable Summary report in ObservePoint data, select the Hard Coded JS account to see all the hard coded JavaScript files.

To capture these details in an audit or web journey, paste the snippet below into an Execute Action:

function opReqGetAsync(paramObject, acct, callback) { 
var baseURL = "" + acct; 
var opReq = new XMLHttpRequest(); 
opReq.onreadystatechange = function() { 
if (opReq.readyState == 4 && opReq.status == 200){ 
}"POST", baseURL, true); 
var object = new Object(); 
var hardcodedJS = document.querySelectorAll('script:not([src*="'+document.domain+'"]):not([src*="'+document.domain.substring(0,document.domain.indexOf("."))+'"])'); 
for(i=0; i<hardcodedJS.length; i++){ 
var jsSRC = hardcodedJS[i].getAttribute('src'); 
jsSRC = jsSRC.replace(/http?s/g,"").replace(/\/\//g,"-").replace(/\//g,"-").replace(/:/g,""); 
object[jsSRC] = "loaded"; 
opReqGetAsync(object,"Hard Coded JS");
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.