Back

The GPT, primarily an Ad Tag. allows you to define ad slots and the criteria or audience you'd like to target through the ad. You may enable this Tag to display a single ad or multiple ads by suitably configuring the Tag.


Prerequisites

  • DFP Account
  • Network Code
  • Ad unit
  • Ad slot creative size

Adding the Tag

This Tag is available in Tealium's Tag Marketplace, which is home to a large selection of vendor Tags. Click here to learn how to add a Tag to your Tealium iQ profile. 

Configuring the Tag

GPT tag config.png

 

Here's how to set up an instance of this Tag for a single ad slot.

  1. Title: Enter a descriptive title to identify the Tag instance. Or you can choose the default "Google Publisher Tag(GPT)".
  2. NC+TAU: Enter the Network Code (NC) and the Targeted Ad Unit (TAU) of the ad slot. These values are available in your DFP account.

    "<em>Example </em>:" /1234/travel/asia/food
    NC = 1234 and Targeted Ad Unit = /travel/asia/food

  3. Enter the Width and Height of the ad slot.
  4. Div ID: Enter the ID of the <div> container for the ad slot. The general format is "div-gpt-ad-#########-#".

    Example:"div-gpt-ad-123456789-0" 

  5. Collapse Empty Div's: Choose whether or not you want the slot to collapse in the event it is not filled by an ad. The default value is set to "Yes". Toggling to "No" will display empty slots.
  6. Library: Select where you want the gpt.js library code to load from:
    • Google (default): Loads the library code from Google's servers.
    • Tealium (RECOMMENDED): Loads the library code via Tealium's code on your webpage. This setting is recommended since it reduces the number of network requests leading to faster page load.

NOTE: You have the option to configure these settings from the Mapping Toolbox.

 

Applying Load Rules

Load Rules determine when and where to load an instance of this Tag on your site. The 'Load on All Pages' rule is the default Load Rule. To load this Tag on a specific page, create relevant Rule conditions to apply to the Tag.
Best Practice: Load this Tag on any page that contains the target ad slot.

 

Here's a sample Load Rule that loads the Tag if the pathname contains "/food".

sample load rule.png

 

Setting up Mappings

Mapping is the simple process of sending data from a data source, in your Data Layer, to the matching destination variable of the vendor Tag. The destination variables for this Tag are available in the Data Mapping toolbox.

For instructions on how to map to a Tag destination, see Mapping Data Sources.

 

mapping toolbox.png

 

Destination Name Destination Variable Description
Network Code networkcode This code is available in the Admin tab of your DFP account
Targeted Ad Unit adunit This is the target Ad Unit
Height height Height of the ad slot
Width weight Width of the ad slot
Set Slot-level Targeting setTargeting_slot Sets the "key:value" parameters for the target ad slot
Example: .setTargeting("interests", "sports");
Set Page-level targeting myvar Sets the "key:value" parameters of all ad slots on a page
NOTE: Replace "myvar" with your custom targeting parameter name.
Example: googletag.pubads().setTargeting("topic","sports");
Multiple Slot Configs gptSlots Define an array of slots for a single page (more details below)
NOTE: Make sure the data source being mapped from contains an array
Collapse Empty DIVs collapseEmptyDivs Collapses ad slots that do not get filled
NOTE: Make sure the data source value contains either "true" or "false"

 

Configuring the Tag for multiple ad slots

Adding and configuring the GPT for a single ad slot is very simple and straightforward. Employing the same process to configure multiple ad slots becomes tedious as you would have to to add an instance of GPT for all the ads you wish to display. The quick alternative is to store all slot configurations in an array then map the array to the 'Multiple Slot Configs' destination in the GPT instance. To create such an array, you can use the JavaScript Code Extension. Make sure to define the slot configs for every ad in this order:
[[Network Code + Targeted Ad Unit, Eligible Creative Size(s), Ad Container DIV ID, Slot-Level Targeting Name/Value Pairs]]

Using the JavaScript Code Extension

Write a JavaScript code that uses the 'googletag.cmd.push' function to define an array of slot configurations for all the ads you wish to display on a page. 

  1. Navigate to the Extensions tab and add the "JavaScript Code Extension" from the Extensions marketplace.
  2. Scope the Extension to "Google Publisher Tag(GPT)".
  3. Write the JavaScript code as you would in any editor. Do not include the <script> tags around the code.

Here's a sample code for configuring 3 ad slots using a single GPT:

googletag.cmd.push(function() {
   googletag.defineSlot("/111/example.com/electronics", [700, 200], "div-gpt-ad-987654321-0").addService(googletag.pubads()).setTargeting("slot_var", "tv");
   googletag.defineSlot("/222/example.com/electronics", [250, 170], "div-gpt-ad-987654321-1").addService(googletag.pubads()).setTargeting("slot_var", "dvd player");
   googletag.defineSlot("/333/example.com/electronics", [300, 100], "div-gpt-ad-987654321-2").addService(googletag.pubads()).setTargeting("slot_var", "smartphone");
   googletag.pubads().enableSingleRequest();
   googletag.pubads().enableSyncRendering();
   googletag.enableServices();
});

TIP: You may choose to use the "u.gptSlots.push()" method instead of "googletag.cmd.push" and reference the NC+TAU value from a data source.
Example: u.gptSlots.push([b.GPT_SlotID, [[728, 90]], 'div-gpt-ad-987654321-0', {"place":"london","theme":"sports"}]);

Vendor Documentation