Introduction to project and interactive demo on my blog: http://esd.io/blog/detecting-adblock-javascript.html
[...]
<script>
// We inline abt.min.js rather than link to it so that it's harder for an Ad Blocker to whitelist
// it. (don't worry it's short!)
// ^^^^ Paste contents of abt.min.js here ^^^^
ad_block_test(function(is_blocked){
// Note this function may not run until some time later.
if(is_blocked) {
// if blocker detected, log a Google Analytics event
var _gaq = _gaq || [];
_gaq.push(['_trackEvent', 'AdTracking', 'AdBlockerDetected', 'ABT detected Ad Blocker in use']);
}
});
</script>
</body>
</html>
See test/ directory for other usage examples and notes
Should work against any ad blocking plugin that subscribes to EasyList (or similar) and collapses ad elements.
Tested against:
Script Goals:
Note: People who block ads may also be blocking your analytics software. Some may even be running NoScript and blocking all javascript on your site.