Question

I am trying to show which users have AdBlock and pass this information to Piwik but it seems to fail. It just shows like everyone got AdBlock enabled..

Here is the code I am using:

function _abpde() {
  if (document.getElementById("AdDiv")==null || document.getElementById("AdDiv").offsetHeight<=0) {
    _paq.push(['setCustomVariable',1,"AdBlock","Enabled","page"]);
  } else {
    _paq.push(['setCustomVariable',1,"AdBlock","Disabled","page"]);
  }
}
window.onload=_abpde();

And I am ussing the div:

<div class="AdDiv" id="AdDiv">&nbsp;asd</div>

Any ideas what I am doing wrong? Thanks!

PS: When I try to remove the document.getElementById("AdDiv")==null the whole script fails and it doesn't even count visits..

Was it helpful?

Solution

window.onload=_abpde();

should be

window.onload=_abpde;

() makes the function execute immediately.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top