Cookie Targeting

Last Updated:
First-Party Cookie Targeting allows you to dynamically target ads to your visitors based on their past behavior. AdGlare features this functionality by reading your visitor's cookie and target a campaign based on your own set of rules. If you or your company have a database full of information of your clients or users, AdGlare's first-party cookie targeting ad server may be an interesting way to increase ROI and cutting down campaign costs.

A real-life example

Imagine you have a webshop on and you have a great advertisement for an iPhone 7. You'd like to offer a 20% discount via a voucher code ad, but only to your loyal customers. Therefore, you'd want to target this campaign only to a small group of people who should:
  • already be a customer
  • have purchased for 100 USD or more in your webshop
  • have shown interest in portable phones
  • not have bought an iPhone 7 already (obviously)
Below I'll explain how you can target such a customer via your AdGlare ad server.

1 Setting up CNAME DNS records

In order for AdGlare to read your cookie, you should enable white-label ad serving. By white-labeling your ad serving domain, ads will be loaded from your subdomain instead of from AdGlare's domains. The browser will then pass on your domain's cookies to our servers, and that's exactly what we want to achieve in the first place. To set this up, follow the instructions on this page (the engine CNAME is of importance here).

2 Storing the cookie in your customer's browser

For this part, you need to be a developer. Briefly, you should query your database, generate a key/value array with your customer's profile and store it JSON-encoded in a cookie. Let's say your customer Lucy logs in to your client area, and you pull all information from this customer from your database. To generate the cookie, first create an associative array with the information that you wish to use for targeting. In the code example below I assume you're using PHP as your programming language.

//prepare variables (fetched from database) $purchase_amount = 120; $interests = array("portables","tablets","usbsticks"); $items_purchased = array("nokia_lumia","64gb_sandisk"); //create cookie array $arr = array(); $arr['is_customer'] = 'yes'; $arr['purchase_amount'] = $purchase_amount; $arr['interests'] = implode("#",$interests); $arr['items_purchased'] = implode("#",$items_purchased); //JSON encode the array $json_array = json_encode($arr); //give the cookie a name $cookie_name = 'my_cookie_name'; //store the cookie for 1 year setcookie($cookie_name, $json_array, time()+31536000, '/', '');

You may want to create a function that checks and re-spawns the cookie in case it's not set, or if the customer's profile has changed.

3 Configuring the campaign

The hardest part is over. To target the campaign to your group of visitors, first enable the Cookie Targeting feature via the flask-icon on the Campaigns page.

Then, click the tab Targeting Rules and define your ruleset based on your cookie configuration (and some common sense regarding the operands).

That's all. Note that if you preview your zone with this campaign, it will not show up. Unless you have a matching cookie profile of course ;)

Share This

Permalink for Bloggers
This article stays online on the following URL:
Ad Server
Ready in 30 seconds
Have a
look Inside

Are you a publisher?

Try AdGlare Ad Server. Get the latest ad technology of 2018, including machine learning and automated A/B testing.