APM - Track clicks on webtop resources
Problem this snippet solves: This configuration sample provide to the administrator a way to log all APM webtop resources clicked by a logged-in user. Those logs can be exported to external systems ...
Updated Jun 06, 2023
Version 2.0Yann_Desmarest
Cirrus
Joined September 11, 2012
Seth_Cooper
Jun 10, 2021Employee
To make this work on Modern Customization the JavaScript needs to be changed. It will be installed in advanced customization under "Webtops" > "[webtop name]" > "user-webtop.js".
window.onclick = function(e) {
if (e.target.className == "apmui-webtop-resource") {
var tID = e.target.id;
console.log(tID);
var xhttp = new XMLHttpRequest();
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(tID)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
if (e.target.parentNode.className == "apmui-webtop-resource") {
var tID = e.target.parentNode.id;
console.log(tID);
var xhttp = new XMLHttpRequest();
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(tID)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
if (e.target.parentNode.parentNode.className == "apmui-webtop-resource") {
var tID = e.target.parentNode.parentNode.id;
console.log(tID);
var xhttp = new XMLHttpRequest();
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(tID)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
if (e.target.parentNode.parentNode.parentNode.className == "apmui-webtop-resource") {
var tID = e.target.parentNode.parentNode.parentNode.id;
console.log(tID);
var xhttp = new XMLHttpRequest();
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(tID)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
};