Script zur Analyse der Ad Blocker-Nutzung auf Websites. Mehr dazu: http://www.121watt.de/analyse-optimierung/google-analytics-ad-blocker-tracken/
<div class="afs_ads"> </div>
<script>
function testAdBlock() {
setTimeout(function() {
if( !document.getElementsByClassName ) return;
var ads = document.getElementsByClassName('afs_ads'),
ad = ads[ads.length - 1];
if(!ad || ad.innerHTML.length == 0 || ad.clientHeight === 0) {
if ( typeof ga !== 'undefined' ) {
ga('send', 'event', 'ads', 'activated', 'ad blocker', { nonInteraction: true });
} else if ( typeof _gat !== 'undefined' && typeof pageTracker !== 'undefined' ) {
pageTracker._trackEvent('ads', 'activated', 'ad blocker', undefined, true);
} else if ( typeof _gaq !== 'undefined' ) {
_gaq.push(['_trackEvent', 'ads', 'activated', 'ad blocker', undefined, true]);
}
} else {
if ( typeof ga !== 'undefined' ) {
ga('send', 'event', 'ads', 'not active', 'ad blocker', { nonInteraction: true });
} else if ( typeof _gat !== 'undefined' && typeof pageTracker !== 'undefined' ) {
pageTracker._trackEvent('ads', 'not active', 'ad blocker', undefined, true);
} else if ( typeof _gaq !== 'undefined' ) {
_gaq.push(['_trackEvent', 'ads', 'not active', 'ad blocker', undefined, true]);
}
}
}, 2000);
}
if ( document.cookie.indexOf('session') <= 0 ) {
if(window.addEventListener) {
window.addEventListener('load', testAdBlock, false);
} else {
window.attachEvent('onload', testAdBlock);
}
}
var d = new Date();
d.setTime(d.getTime()+1800000);
var expires = 'expires='+d.toGMTString();
document.cookie = 'session=1; '+expires+'; path=/';
</script>