Adobe External Links

This code matches all external links, based on Adobe Analytics internalFilters definition.

The following item shows up in the Variable Summary report under the OP Custom Tag. The account is External Links.
  • externalLinks0-nn: Shows all the external links by page.
  • externalLinks.length: Shows the count of pages with external links by page.
  • internalFilters: Shows a list of internal filters that were found on the page.
  • page: Shows the display URL and the actual URL of the pages where the download links were found.

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 = "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)); 
} 
function externalLinksCheck(){ 
var object = {}, 
extLinks = [], 
adobeObject = window['s'] || "s not found", 
links = Object.keys(document.querySelectorAll('a[href]')).map(function(key){return document.querySelectorAll('a[href]')[key]}); 
console.log(adobeObject); 
if(typeof adobeObject == "object"){ 
var regEx = new RegExp(s.linkInternalFilters.replace(/,/g,"|"),"g"); 
for (var i = links.length - 1; i >= 0; i--) { 
if(links[i].href.search(regEx) == -1){ 
extLinks.push(links[i].href) 
} 
}; 
object.page = location.href; 
extLinks.length == 0 ? object.externalLinks = "No external links found" : object.externalLinks = extLinks; 
opReqGetAsync(object, "External Links"); 
} else { 
object.internalFilters = "Internal filters not found on current page"; 
opReqGetAsync(object, " External Links");} 
}externalLinksCheck();
	
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.