Site logo

Archived topic

Tracking Adblockers traffic

3 replies · Started by Patricia on March 14, 2022

Viewing posts 1–4 of 4

Hi guys! Hope you all had a great weekend!

I am trying to track adblocker traffic, and I have found this code down here. My question is, how do I add this to Generatepress theme, and would like to ask if you by any means know a quick and safe way to do this? Thank you! :)

if(typeof adsbygoogle !== \"undefined\") {
window.addEventListener(\'load\', function() {
if(typeof ga !== \"undefined\") {
if(typeof adsbygoogle.loaded === \"undefined\") {
ga(\'send\', \'event\', \'AdSense\', \'Ads blocked\', { \"nonInteraction\": 1 });
} else {
ga(\'send\', \'event\', \'AdSense\', \'Ads not blocked\', { \"nonInteraction\": 1 });
}
}
}, false);
}

Hi there,

it looks like a script.
So you can try:

1. Create a new Hook Element.
https://docs.generatepress.com/article/hooks-element-overview/
2. In the Hook Element add your code wrapped in <script> tags ie.

<script>
   add the code in here
</script>

3. Set the Hook to wp_header
4. Set the Display rule to where you want it applied. eg. Entire Site

thank you so much! :) have a great week!

You're welcome - you too :)

This archived topic is closed to new replies.