Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - All Hard Coded JavaScript Files
OP Custom Tag - All Hard Coded JavaScript Files
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 6 months ago

Overview

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 hardcoded JavaScript files.

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

function opReqGetAsync(paramObject, acct, callback) {
var baseURL = "https://opreq.observepoint.com/?acct=" + acct;
var opReq = new XMLHttpRequest();
opReq.onreadystatechange = function() {
if (opReq.readyState == 4 && opReq.status == 200) {
callback(opReq.responseText);
}
}
opReq.open("POST", baseURL, true);
opReq.send(JSON.stringify(paramObject));
}
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');
if (jsSRC) {
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?