I set a cookie to certain user groups, Ezoic then don't display ads to those browsers with cookies.
I use GTM to set the cookie on login.
1. I have a custom JS variable, which returns the member group:
function() {
return window.groupId
}
2. I have a lookup table which then changes the output as it's just the DB number of the group and I'd like it readable
3. Then I have a custom HTML tag to create a cookie with noAdverts = true
<script>
var memberType = {{Lookup table - Group ID}};
if (memberType === 'Admin' || memberType === 'Moderator' || memberType === 'YOC Member' || memberType === 'Supporter' || memberType === 'Corporate') {
var expirationTime = 7776000; // THREE month in seconds
expirationTime = expirationTime * 1000; // Converts expirationtime to milliseconds
var date = new Date();
var dateTimeNow = date.getTime();
date.setTime(dateTimeNow + expirationTime); // Sets expiration time (Time now + one month)
var expirationTime = date.toUTCString(); // Converts milliseconds to UTC time string
document.cookie = "noAdverts = true; expires=" + expirationTime + "; path=/; domain=." + location.hostname.replace(/^www\./i, ""); // Sets cookie for all subdomains
}
</script>
4. Ezoic's tech team make a change their end to only allow ads to be served to non cookied browsers
It's not perfect, as I didn't bother to set a script to remove the cookie on logout. But I also didn't want those users to see ads if they did log out, so set a 3 month expiry.
It's possible for anyone to manually create the same cookie value and they wouldn't see ads, but I think it's very unlikely for someone to do this.