How to hide adsense ads to visitors coming from specific campaign?
Until now, I've found the way to hide ads when the URL contains the word "share"
For example:
it won't show the adsense ad if the landing page of my campaign is:
https://example.com/?utm_source=social&utm_medium=share
I use the following code to do that:
<?php
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'share') !== false) {
return false;
} else { ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-0000000000000000"
data-ad-slot="0000000000"
data-ad-format="link"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php } ?>
The problem is, when the visitor goes to another page within my website, the utm parameter is removed from the URL, and adsense ad show up again.
I need your help to make sure any visitor coming from campaign
?utm_source=social&utm_medium=share
don't see any adsense ad, no matter if the visitor navigate my entire website, the visitor should not see the adsense ad.
If you know another workaround for this problem, something more simple, please share it. I will forget the code above and use yours.
Thank you in advance for your responses.
Regards