Is it possible to serve different ads based on the value of a cookie? Following is the use case, user whos subscription is about to end in next 15 days vs user who has not subscribed even once vs user whos subscription expired a week back. A cookie will be set which will have different values & different ad need to be displayed based on the cookie value.
AdPlugg unfortunately doesn't have that capability. However, You could accomplish the same thing by serving different Ad Zones to different users based on their subscription status.
Example (PHP):
For example, you could do something like this in PHP:
<?php
$zone;
switch ( $user->getSubscriptionStatus() ) {
case 'SUBSCRIBED':
$zone = 'YOUR_SUBSCRIBER_ZONE';
break;
case 'EXPIRING':
$zone = 'YOUR_EXPIRING_ZONE';
break;
default:
$zone = 'YOUR_ANONYMOUS_USER_ZONE';
}
echo '<div class="adplugg-tag" data-adplugg-zone="' . $zone . '"></div>';
?>
Example (JavaScript):
You could also do it client side with JavaScript like this:
<script>
(function() {
function getCookie(name) {
var match = document.cookie.match(RegExp('(?:^|;\\s*)' + name + '=([^;]*)'));
return match ? match[1] : null;
}
// Get the subscription status from the cookie.
var subscriptionStatus = getCookie('subscription_status');
// Determine which Zone to serve.
var zone;
switch (subscriptionStatus) {
case 'SUBSCRIBED':
zone = 'YOUR_SUBSCRIBER_ZONE';
break;
case 'EXPIRING':
zone = 'YOUR_EXPIRING_ZONE';
break;
default:
zone = 'YOUR_ANONYMOUS_USER_ZONE';
}
// Drop the Ad Tag.
var adTag = document.createElement('div');
adTag.className = 'adplugg-tag';
adTag.dataset.adpluggZone = zone;
document.getElementById('my-sidebar').appendChild(adTag);
// Fill the Ad Tag.
AdPlugg.push({'command':'run'});
}());
</script>
Please contact us for help with your own similar scripts.
We also do custom development and could potentially develop something for your particular use case. Please contact us if you are interested.
Edit 2021-09-21: added examples.