Skip to main content
All CollectionsReferrals
How to block referrals from Google Ads
How to block referrals from Google Ads
Emmet Gibney avatar
Written by Emmet Gibney
Updated over 10 months ago

If you wish to prevent affiliate referrals coming from Google Ads you can add a short piece of JavaScript to your website to remove the cookie that gets placed for these referrals.

Simply add this JavaScript snippet below the Rewardful Tracking snippet in the <head> section of your website.

<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js"></script>

<script>
$(function(){
let referral_url = new URL(window.location.href);
if (referral_url.searchParams.has('gclid') && referral_url.searchParams.has('via')) {
setTimeout(function(){
Cookies.remove('rewardful.referral', { path: '/', domain: window.location.hostname })
console.log(Cookies.get('rewardful.referral'))
console.log("Deleted referral cookie as visit came from Google Ads (forbidden by Terms of Service)")
}, 2000)
}
});
</script>

If you do this it is also advisable to add a clause to your affiliate program's terms of service that makes it clear to your affiliates that this behaviour is prohibited.

Did this answer your question?