OP Custom Tag - Collecting Network Request URLs
Overview
This custom tag collects network requests executed on a page, except those that have not been marked with performance tracking.
Note: This custom tag should capture about 90% of network requests.
Under Variable Summary in ObservePoint Data, select the Other Network Urls account to see the relevant variables.
- 0-xx: Shows the source of where URL links are generated and the subsequent URL.
- length: Shows the number of links found by page.
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 arr = window.performance.getEntries(); var resultArr = []; for (var i = arr.length - 1; i >= 0; i--) { if (arr[i].name.indexOf('http') === 0) resultArr.push(arr[i].name) }; opReqGetAsync(resultArr, " Network Urls");