Created
April 6, 2024 15:20
-
-
Save soulbliss/10faaa89ff26d6eb85b7eb24dfc1273a to your computer and use it in GitHub Desktop.
Marc Louvion's script to nuke affiliate cookie
Here is the vanilla javascript approach.
<script> document.addEventListener("DOMContentLoaded", function() { // Create a new URL object based on the current window location let referral_url = new URL(window.location.href); // Check if the URL contains 'gclid' and 'via' parameters if (referral_url.searchParams.has('gclid') && referral_url.searchParams.has('via')) { // Set a timeout function to delete a specific cookie after 2 seconds setTimeout(function() { // Set the cookie to expire in the past, effectively deleting it document.cookie = 'rewardful.referral=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=' + window.location.hostname; // Log a message to the console console.log('Deleted referral cookie as visit came from Google Ads (forbidden by Terms of Service)'); }, 2000); } }); </script>
Thanks @brettbatie lgtm!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the vanilla javascript approach.