Set up Targeting

There are 3 ways to set targeting in HTL BID

  • GPT functions
  • Inline data-targeting attribute
  • HTL BID user interface

Using GPT functions

HTL BID supports the normal GPT targeting functions. This is normally used to set page-level targeting.

googletag.cmd.push(() => {
  googletag.pubads().setTargeting('key', 'value');
});

To pass multiple values for the same key use an array of strings: setTargeting('key', [ 'value1', 'value2']);

Using inline attributes

HTL BID supports targeting using inline DIV attributes through the data-targeting attribute. This is normally used to dynamically set slot-level targeting

<div class="htlad-leaderboard" data-targeting='{"category": ["sports", "news"]}'>
</div>

Note that the value of data-targeting MUST be valid JSON.

If you have enabled Amazon APS, you can also set slot-level key-value targeting for Amazon, by using the data-amazon-targeting attribute.

Using the HTL BID user interface

HTL BID supports targeting through the HTL BID user interface. This is normally used to statically assign slot-level targeting.

To set targeting in the UI

  • Navigate to Ad Configuration > Slot Setup
  • Expand the target slot
  • Click Add Slot-level Key-Value Targeting
image

Then input the key and value that you want to set for that slot.

If you have enabled Amazon APS, you can also configure targeting key-values to Amazon, by choosing Type=Amazon

image

Which one should you use?

There are 2 main considerations when deciding which method to use:

Do you require page-level or slot-level targeting?

  • Page-level targeting is used to set values that are the same for the entire page. For example, setting page_type=article is typically page-level.
  • Slot-level targeting is used to set values that differ on every slot. For example, a value such as pos=top is typically slot-level, since it describes the position of a specific slot.

Do you require static or dynamic targeting?

  • Static targeting means that the value is the same every time. The values are known in advance and never change.
  • Dynamic targeting means that the values changes dynamically, cannot be set in advance, and must be set on-the-fly using javascript. A typical example of dynamic targeting is inserting multiple slots within an article, with values such as pos=inline-1, pos=inline-2, pos=inline-3

If you need..

  • Page-level targeting, use the standard GPT functions
  • Static slot-level targeting, use the HTL BID user interface
  • Dynamic slot-level targeting, use the inline data-targeting attribute