Skip to main content
Skip table of contents

How to Use Custom GAM Key-Values

There are two ways to pass custom key-value pairs to GAM. 

  1. Using properSpecialOps.page_meta

  2. Directly on your Google Publisher Tag (GPT) 

properSpecialOps.page_meta

Use the dfp_kv property (object) within properSpecialOps.page_meta to pass page-level key-value pairs directly to GAM.

JS
properSpecialOps = window.properSpecialOps || {};
properSpecialOps.page_meta = {
  "dfp_kv": {
    'sport': 'baseball',
    'team': 'padres'
  }
}

Note: Note, there is a limit of 20 characters on keys and 40 characters on values.

GPT Reference

Before getting started, make sure you're familiar with this page from the Google Developer Center. Start there if you need, and then come back to this resource for some Sovrn Ad Management-specific examples. 

Please visit properSpecialOps and Custom Variables to see all custom variables that you can use with us.

Page-Level Targeting

This feature allows publishers to set GAM key values across all of your ad slots on the page. Publishers might want to use this targeting feature in GAM to reduce the total amount of ad code on-page to better optimize targeting.

Use the following command to initiate this feature:

CODE
googletag.pubads().setTargeting()

Here is an example of this code: 

CODE
<script type="text/javascript">
// Define propertag
  var propertag = {};
  propertag.cmd = [];     
// Page-level targeting with single value per key
  propertag.cmd.push(function() {
    googletag.pubads().setTargeting('interests', 'basketball');
  });     
// Page-level targeting with multiple values for a single key.     
  propertag.cmd.push(function() {
    googletag.pubads().setTargeting('interests', ['baseball', 'basketball']);
  });     
// Page-level targeting with multiple keys      
  propertag.cmd.push(function() {
    googletag.pubads().setTargeting('interests', 'basketball');       
    googletag.pubads().setTargeting('position', 'atf');
  }); 
</script>

Here is an example of Ad Management variables & Google Ad Manager Key-Values

HTML
 <script type="text/javascript">
  var propertag = propertag || {};
  propertag.cmd = propertag.cmd || [];
  var properSpecialOps = properSpecialOps || {};
  properSpecialOps.tags = ['interests=basketball'];
  propertag.cmd.push(
    function() {
    googletag.pubads().setTargeting('interests', 'basketball');
    }
  );
  (function() {
    var pm = document.createElement('script');
    pm.async = true; 
    pm.type = 'text/javascript';
    var is_ssl = 'https:' == document.location.protocol;
    pm.src = (is_ssl ? 'https:' : 'http:') + '//global.proper.io/website.min.js';
    var node = document.getElementsByTagName('script')[0];
    node.parentNode.insertBefore(pm, node);
  })(); 
</script>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.