JS Tag Example of How Information is Sent in an Ad Request (UAS)

Document created by catherine.racette on Apr 28, 2017Last modified by catherine.racette on Aug 21, 2017
Version 4Show Document
  • View in full screen mode

Important Notes:

The string 'Div_ID_To_Render_This_Slot' must be replaced in JS tags using the following guidelines:

  • ID token must begin with a letter ([A-Z,a-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-") and underscores ("_").
  • It is a case-sensitive string
  • ID must be unique on the page

 

Example of how information is sent in the ad request. Note that multiple ad slots can be sent in the same script. See example below to understand how we pass key values for one or multiple ad slots.

 

<!-- Part 1 -->
<!-- Head section, should be included only once on a page -->
<script type='text/javascript'>
        var Phoenix = {};
     Phoenix.EQ = [];
     (function(){
          var scriptElement = document.createElement('script');
          scriptElement.async = true;
          scriptElement.type = 'text/javascript';         
          scriptElement.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + '//ads.pubmatic.com/AdServer/js/phoenix.js';
          var node = document.getElementsByTagName('script')[0];
          node.parentNode.insertBefore(scriptElement, node);                   
     })();
</script>
<!-- Part 2 -->
<!-- AdSlot declaration section, will repeat for number of slots -->
<script type='text/javascript'>
     Phoenix.EQ.push(
          function(){
               Phoenix.enableSingleRequestCallMode();
                                       
               // set common key-value targertings
               Phoenix.setCommonTargeting('age', [24, 25, 26, 27]);
               Phoenix.setCommonTargeting('city', ['new york', 'pune']);              
              
               // setting custom  parameter
               // as of now, we support only four custom parameters
               Phoenix.setInfo('PAGEURL', 'http://publisher-site.com'); // passing page-URL as param(dpurl)
               Phoenix.setInfo('LAT', '78.43'); // passing lat-long
               Phoenix.setInfo('LON', '34.84'); // passing lat-long
               Phoenix.setInfo('SEC', '1'); // if set to '1', ad-engine will select only secure creatives
              
               // set common keywords to be passed
               // NOTE: this feature is currently turned off
               Phoenix.setCommonKeywords(['year end', '2016', '2017', 'new year']);
              
               // Defining ad-slot    
               var adSlot = Phoenix.defineAdSlot('1146',,'Div_ID_To_Render_This_Slot');
               // set targeting on ad-slot
               adSlot.setTargeting('ATF', ['1']);
               adSlot.setTargeting('gender', ['M', 'male']);
               // set key-words on ad-slot
               // NOTE: this feature is currently turned off
               adSlot.setKeywords(['Dev', 'software', 'QA']);
              
          }
     );    
</script>

 

Passing Multiple Ad Slots in a Single Script

In the example below, we define 4 ad slots (topp1 to topp4) and we add two key value pairs:

  • TEST01 for all four slots
  • TEST02 for slot topp4, hence we use a variable s4 in order to target the ad slot.
 <script type='text/javascript'>
      Phoenix.EQ.push(function(){
        Phoenix.enableSingleRequestCallMode();
        Phoenix.setCommonTargeting('section', "TEST01");
         Phoenix.defineAdSlot('10002089',,'ad-to-wrap-topp1');   
        Phoenix.defineAdSlot('10002114',,'ad-to-wrap-topp2');
        Phoenix.defineAdSlot('10002115',,'ad-to-wrap-topp3');
        var s4 = Phoenix.defineAdSlot('10002116',,'ad-to-wrap-topp4');       
        s4.Phoenix.setTargeting('Section', "TEST02");
      });
    </script>

Attachments

    Outcomes