APM - Track clicks on webtop resources
Updated Jun 06, 2023
Version 2.0Was this article helpful?
Well close.. Still didn't seem to be hitting 100%. But the following modification seems to be working much better..
window.onclick = function (e) {
if (e.target.parentNode.className == "favorite" || e.target.parentNode.className == "image" || e.target.parentNode.className == "caption") {
var xhttp = new XMLHttpRequest();
console.log(e.target.parentNode.id);
var parentNodeId = "";
//populate parent's parent
if (e.target.parentNode.parentNode.id) {
parentNodeId = e.target.parentNode.parentNode.id;
}
//overwrite parent's parent if parent not null
if (e.target.parentNode.id) {
parentNodeId = e.target.parentNode.id;
}
//open link
if (parentNodeId) {
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(parentNodeId)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
//log failed result
else {
console.log("Parent ID is NULL");
}
}
};