Last active
August 29, 2015 14:10
-
-
Save chrisblakley/ca7a61aa054402248d1b to your computer and use it in GitHub Desktop.
Detect if users are blocking your ads using jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.hidden {display: none;} /* Just for reference. This should be in your stylesheet! */ | |
</style> | |
<div class="extra_resources"> | |
<!-- [AD_CODE_HERE] --> | |
</div> | |
<a class="blockdetection hidden" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VALMBPW4PWH8S" target="_blank"><img src="donate_image.png" alt="Donate via Paypal" /></a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).on('load', function(){ | |
if ( $('.extra_resources').length ) { | |
if ( $('.extra_resources').height() < 1 ) { | |
$('.blockdetection').removeClass('hidden'); | |
ga('send', 'event', 'Ads Blocked', 'Using Browser Extension'); //Log the event in Google Analytics | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment