Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - Google Link Attributes
OP Custom Tag - Google Link Attributes
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 6 months ago

Overview

This custom tag collects all the links that are missing the correct attributes for Google. This is an important feature to look for because it helps to differentiate between links to the same URL located in different locations on a page. In Google Analytics it is called Enhanced Link Attribution. Using this data in GA, heat maps can be generated to see the general interactions with the URL links.

Under Variable Summary reports in ObservePoint data, select the Google Attributes account to see relevant variables.

  • failed.0-xx: Shows the pages that are missing the correct attributes for Google Analytics.

  • failed.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));
}
"

function toArray(obj) {
var array = [];
// iterate backwards ensuring that length is an UInt32
for (var i = obj.length >>> 0; i--;) {
array[i] = obj[i];
}
return array;
}
var links = toArray(document.querySelectorAll("a"));
var attr = toArray(document.querySelectorAll("a[data-g-action][data-g-event][data-g-label]"));
var objectAttr = {};
objectAttr.failed = [];
for (k = 0; k < links.length; k++) {
if (attr.indexOf(links[k]) == -1) {
objectAttr.failed.push(links[k].outerHTML);
}
}
opReqGetAsync(objectAttr, " Google Attributes");
Did this answer your question?