Page load rule and data element question
I created a script that identifies if a visitor's browser is using adblocker. I added the script to the page load rule (top of page) and it works and returns a console.log for the return statement. However, how would I capture the return statement in a data element? I tried creating a data element with custom code to "return adBlockDetection;" but that didn't seem to work?
Am I missing something?
code added to the custom page code in the page load rule (top of page):
var adBlockDetection = (function() {
var test = document.createElement('div');
test.innerHTML = ' ';
test.className = 'adsbox';
document.body.appendChild(test);
if (test.offsetHeight === 0) {
console.log("AdBlocker Status: Active");
return "AdBlocker Status: Active";
} else {
console.log("AdBlocker Status: None");
return "AdBlocker Status: None";
}
})();