Friday, 30 December 2016

How To Track Visitors Blocking Your Ads In WordPress


Have you ever wanted to know exactly how many people visiting your WordPress website are blocking your ads? If so, you’re in luck. This guide will show you how to tag new sessions from visitors using AdBlockers with a Google Analytics custom event. Then show you how to segment users with AdBlockers via an advanced segment in Google Analytics. How To Track AdBlock Users with Google Analytics (without Google Tag Manager)
Add the following code right after your Google Analytics tracking code in the body of your theme’s “header.php” file:
123456789101112131415161718192021
<?php session_start();if(empty($_SESSION[‘exists’])){echo " var adBlockEnabled = false; var testAd = document.createElement(‘div’); testAd.innerHTML = ‘ ‘; testAd.className = ‘adsbox’; document.body.appendChild(testAd); window.setTimeout(function() { if (testAd.offsetHeight === 0) { ga(‘send’, { hitType: ‘event’, eventCategory: ‘adBlocker’, eventAction: ‘detected’ }); } testAd.remove(); }, 100); ";}$_SESSION[‘exists’] = true; ?>
If you encounter any errors related to sessions with the above code, use the following code instead:
1234567891011121314151617
Source: https://managewp.org/articles/14102/how-to-track-visitors-blocking-your-ads-in-wordpress




source https://williechiu40.wordpress.com/2016/12/30/how-to-track-visitors-blocking-your-ads-in-wordpress/

No comments:

Post a Comment