How to Track AdBlock Users with Google Analytic?

Discussion in 'Google Analytics' started by webgames247, Feb 29, 2016.

  1. #1
    Hi All,

    Is there a way i can track how many user come to my site with abblock using google analytic?

    Thanks,
     
    webgames247, Feb 29, 2016 IP
  2. Overfreeze

    Overfreeze Active Member

    Messages:
    16
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    65
    #2
    Hello Webgames247, there is a way to do this with code.
    Open your website template and copy-paste the snippet below before the closing.
    This code will detect the presence of adblocking on the visitor’s browser and an event gets logged into your Google Analytics account.


    1. <script>
    2. window.onload =function(){
    3. // Delay to allow the async Google Ads to load
    4. setTimeout(function(){
    5. // Get the first AdSense ad unit on the page
    6. var ad = document.querySelector("ins.adsbygoogle");
    7. // If the ads are not loaded, track the event
    8. if(ad && ad.innerHTML.replace(/\s/g,"").length ==0){
    9. if(typeof ga !=='undefined'){
    10. // Log an event in Universal Analytics
    11. // but without affecting overall bounce rate
    12. ga('send','event','Adblock','Yes',{'nonInteraction':1});
    13. }elseif(typeof _gaq !=='undefined'){
    14. // Log a non-interactive event in old Google Analytics
    15. _gaq.push(['_trackEvent','Adblock','Yes',undefined,undefined,true]);
    16. }
    17. }
    18. },2000);// Run ad block detection 2 seconds after page load
    19. };
    20. </script>
     
    Overfreeze, Mar 5, 2016 IP
    webgames247 likes this.