All Collections
ObservePoint Custom Tag
OP Custom Tag - Links List
OP Custom Tag - Links List
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over a week ago

Overview

This custom tag collects a simple inventory list of all the anchor tag links on the audited pages. The links are not clicked, just collected. This custom tag will also get a list of href attributes.

Under Variable Summary in the ObservePoint Data vendor, select the Links List account to access the relevant variables.

  • Link_Count: Shows the total number of anchor tags for each URL.

  • Links_List: Shows a list of all the anchor tags for each URL.

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 links = document.getElementsByTagName('a'),
allLinks = [];
for (var i = 0; i < links.length; i++) {
if (links[i].href != ""
"") {
allLinks.push(links[i].href);
} else {
allLinks.push(links[i].innerHTML);
}
}
allLinks = allLinks.join(', ');
var obj = {
""
Link_Count "": links.length,
""
Links_List "": allLinks
};
opReqGetAsync(obj, "Links List");
Did this answer your question?