Jaxel's Implementation of Ad Block Detection

Jaxel's Implementation of Ad Block Detection

Well a few weeks ago, I wrote a guide on how to Differentiate members from guests in Google Analytics reports... Well, you can actually combine that guide and this guide to create custom reports to differentiate users who are detected using adblock and those who arent!

In the Google Analytics guide I wrote, I used custom data key 1 to handle registration reports. In this specific case for ad servers, I will be using custom data key 2. Sending the data to Google Analytics is as simple enough as making a slight change to your adblock detection javascript:
Code:
$(document).ready(function () {
    if ($('.adContainer').length == 0 || $('.adContainer').height() == 0)
    {
        $('.noticeContainer').removeClass('hidden');
        _gaq.push(["_setCustomVar", 2, "Adview", "blocked", 3]);
        _gaq.push(['_trackPageview']);
    }
    else
    {
        _gaq.push(["_setCustomVar", 2, "Adview", "served", 3]);
        _gaq.push(['_trackPageview']);
    }
});
Thats it! The data is now being sent to Google Analytics, and you can follow the steps in the other guide on how to view the custom data.
Top Bottom