Skip to content

Custom targeting

What is a custom targeting?

A custom targeting is a key-value pair of strings which will be added to the ad request. This key-value pair can be used to target an ad to a specific keyword.

For example:

  • gender=male
  • age=20-30
  • carbrand=bmw
  • temperatur=25
  • category=news

Those keywords can be defined by yourself.

Important note

Before you add targeting parameters please contact first your ad-serving partner. In some cases the keyword targeting parameters must be added to your ad server before you can use it and in some cases they must be in a special format like the profile targeting on Adition ad server.

Why should I add a custom targeting?

A campaign which is targeted to a specific keyword can be sold for a higher CPM (TKP).

How can I add a custom Targeting?

Add the targeting parameters before you call the initialize method.

banner = new ADvantage_WebSDK( 'advertisement' )
    ...
    .addAdserverTargeting( 'gender', 'male')
    .addAdserverTargeting( 'age', '20-30')
    .addAdserverTargeting( 'category', 'news')
    .initialize();

Please Note

All targeting key-pairs will be stored for each instance in an array and will be transmitted for each ad request.

How can I update a custom Targeting for reloading the current instance?

When you would like to reload the current ad position to request a new ad and you want to update a specific targeting parameter call addAdserverTargeting with the key and the new value and reload the position with reload. The old key will be overwritten with the new value.

In our example we are updating the category from news -> sport and reloading the current ad position.

banner
    .addAdserverTargeting( 'category', 'sport')
    .reload();

How can I remove a custom Targeting from the array?

If you want to reload the ad position to request a new ad and you want to remove a specific targeting parameter call removeAdserverTargeting with the key and reload the position with reload.

In our example we remove the key gender and age from the array and we reload the current ad position.

banner
    .removeAdserverTargeting( 'gender' )
    .removeAdserverTargeting( 'age' )
    .reload();

A more complex example

// We initialize with some standard values
banner = new ADvantage_WebSDK( 'advertisement' )
    .setLicenseKey( '[LICENSE KEY]' )
    .setSiteId('[SITE ID]')
    .setPosition('[POSITION]')
    .setWidth( '320px' )
    .setHeight( '50px' )
    .addAdserverTargeting( 'gender', 'male')
    .addAdserverTargeting( 'age', '20-30')
    .addAdserverTargeting( 'postcode', '90210')
    .addAdserverTargeting( 'category', 'cars')
    .addAdserverTargeting( 'price', '10000')
    .initialize();

...
// Now we want to change and modify the targetings for the next ad request
// subcategory will be added
// postcode will be changed
// price will be removed
banner.addAdserverTargeting( 'subcategory', 'kia' )
    .removeAdserverTargeting( 'postcode')
    .addAdserverTargeting( 'price', '20000' )
    .reload();