PRODUCT
Follow

Overview

As a publisher, you can use Peer39 to make your inventory more relevant. The Peer39 page-level, semantic technology allows publishers to:

  • Better understand inventory

  • Charge more for higher-quality inventory

  • Boost ROI

Implementing Peer39 across your site and/or group of properties expands and improves your real-time targeting capabilities by:

  • Creating a unified taxonomy

  • Finding more premium content

  • Enabling cross-site sponsorships

  • Automating brand alignment with improved and customized brand safety

  • Accommodating custom targeting requests

  • Expanding the size and reach of audience segments

Peer39 JavaScript Tag Implementation for Publishers

How Does It Work?

Publishers implement Peer39 by using a JavaScript tag and corresponding callback function.

  • When a webpage loads, the Peer39 JavaScript tag calls the Peer39 service.

  • Peer39 sends page-level classifications back to the page.

  • The Peer39 callback function passes the classifications to your ad server and/or DMP.

  • These Peer39 classifications are now available in your ad server or DMP and can be used for targeting in real time.

Technical Overview

This overview provides the technical details and steps required to implement the Peer39 JavaScript tag and callback function, including placement of tags and the methods to dynamically modify existing ad serving or DMP tags to include the Peer39 category IDs for real-time targeting.

Akamai Edge servers host the Peer39 JavaScript tags to provide maximum redundancy with minimal latency. When a browser loads a page with a Peer39 tag, that page sends a classification request to the Akamai Edge servers. The browser receives the Peer39 classification response, which can be passed to the ad server or DMP using the Peer39 afterFinished() callback function.

Since a single page URL may have multiple classifications, the Peer39 category IDs that get passed to the ad server or DMP represent the Peer39 Content, Quality, and Safety classifications of the page.

  • Content: Content of the page (for example, Automotive)

  • Quality: Structure of the page (for example, Content Rich Environment - CRE )

  • Safety: Safety of the page (for example, Safe from Mature)

Note

Note: The Peer39 JavaScript tag is not a cookie-based pixel and provides classification that is solely dependent on the page and page content, not the user. The Peer39 categories may be passed to your DMP to segment users; however, the information that is provided is specific to the page and page content being viewed.

Peer39 JavaScript Tag

This is an example of a Peer39 JavaScript tag. (AID represents a unique Peer39 account ID.)

<script id="peer39ScriptLoader" type="text/JavaScript" 
src="http://stags.peer39.net/AID/trg_AID.js"></script>          

Important

Important: Implementation tips for the Peer39 JavaScript tag:

  • Place the tag on publicly-accessible pages that do not require authentication or login to access the content.

  • Place the tag in the head* section of the HTML. You can implement the tag directly on the page or through a container tag that already appears on the page.

Note

Note: Depending up on your site’s specific structure and JavaScript execution, it may be necessary to place the Peer39 JavaScript tag at the bottom of the HTML, within the body, as an alternative to placing it within the head.

Upon page load, this tag allows Peer39 classification engines to access the page content for classification and to return Peer39 category IDs to the page. Using the Peer39 Callback function, the Peer39 category IDs are then passed into your ad server or DMP through the subsequent ad tag and DMP calls.

Peer39 afterFinished() Callback Function

The following code represents an example of the Peer39 afterFinished() callback function. (AID represents a unique Peer39 account ID.)

<script type="text/JavaScript">

// A variable to hold the Peer39 category IDs


var 
p39_ids = '';

var ord = Number(ord) || Math.floor(Math.random()*10e12);

//
 
afterFinished function

function afterFinished_AID(){

     // gets the Peer39 Categories



     p39_ids= p39_KVP_Short('p', ',');

     // passes Peer39 Categories to ad call

                 
    document.getElementById('adSlot1').innerHTML='<iframe src="http://adserver.com/ads?

adslot=leaderboard&ord=' + ord +  '&Targeting=' + p39_ids + '" width=300 height=250

 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0  scrolling=no

 bordercolor="#000000">';

}

</script>
       

Important

Important: Implementation tips for the afterFinished() function:

  • Place the afterFinished() function in the body of the HTML.

  • If you want to pass Peer39 category IDs into ad calls, include the ad calls in the afterFinished() function.

Procedure
  1. Load the Peer39 JavaScript tag for every page load.

  2. Peer39 sends the Peer39 category IDs (classifications) back to the page.

  3. Run the afterFinished() callback function to retrieve the category IDs.

  4. In the afterFinished() function, store the Peer39 Category IDs in a JavaScript variable (for example, p39_ids).

  5. In the afterFinished() function, make one or more ad calls and dynamically pass the Peer39 category IDs into the ad calls by using the JavaScript variable that stores these IDs.

Implementation with Key Value Pairs: p39_KVP_Short()

If Peer39 Category IDs must be passed as Key Value pairs, (for example, p=1101&p=1121&p=2322), use the p39_KVP_Short() function to store the categories into the designated JavaScript variable. For example:

var p39_ids = p39_KVP_Short(p,&);

To change the prefix (p) or delimiter (&), simply the edit the parameters when calling the p39_KVP_Short() function. For example, if the prefix and delimiter (p) and (&) are replaced with (i) and (,) respectively, the function should look like this p39_ids=p39_KVP_Short('i', ','); and the resulting category IDs will be passed as i=1101,i=1121,i=2322.

Example:

<html>
<head>
<script id="peer39ScriptLoader" type="text/JavaScript"


 src="http://stags.peer39.net/AID/trg_AID.js "></script>
</head>
<body>

<div id=adslot1>

</div>
<script type="text/JavaScript">
//variable to hold 
the Peer39 categories
var 
p39_ids = '';

//afterFinished function
function 
afterFinished_AID() {
 //Storing Peer39
 Categories
 p39_ids = p39_KVP_Short('p', '&');

 var ord = Number(ord) || 
Math.floor(Math.random() * 10e12);

 //Passing the Peer39 
categories into the Ad Tag

 document.getElementById('adslot1').innerHTML = 
'<iframe src = "http://youradserver.com/ads?
adslot=leaderboard&w=300&h=250&ord=' + ord + 
'&p39=' + p39_ids + '" width=300 height=250 
marginwidth=0 marginheight=0 hspace=0 vspace=0
 frameborder=0 scrolling=no 
bordercolor="#000000">';
}                                  
</script>
</body>
</html>
        

Live Example Using p39_KVP_Short()

Click here to see how the Peer39 tag is typically implemented. For a better understanding, make sure to view the source code and observe all calls generated when the page loads.

This example meets all the requirements necessary for a successful implementation.

Implementation with Google Publisher Tag (GPT): p39_GPT_value()

After review of Peer39 JavaScript Technical Overview and basic setup, follow these instructions, specifically for Google Publisher Tag (GPT) clients, who want to implement with the Peer39 JavaScript Tag.

Note

Note: Peer39 JavaScript tag implementation requires GPT be in asynchronous mode to pass Peer39 Category IDs into the GPT ad calls.

Procedure
  1. Load the Peer39 JavaScript tag upon every page load.

    Peer39 responds by sending the category IDs (classifications) back to the page.

  2. Run the afterFinished() callback function to retrieve the category IDs.

  3. Within the afterFinished() function, run googletag.cmd.push().

  4. Within the afterFinished() function, use the p39_GPT_value() function to push the Peer39 Category IDs into the GPT .setTargeting() function:

    .setTargeting("Peer39", p39_GPT_value())

The following is a sample script that shows the Peer39 Category IDs being passed into GPT:

<html>
<head>
//PEER39 CODE - implementing Peer39 script on the page
<script
 id="peer39ScriptLoader" type="text/JavaScript" 
src="http://stags.peer39.net/AID/trg_AID.js"></script>
//GOOGLE CODE - implementing 
and running GPT.JS script
<script type="text/JavaScript">
  var googletag = googletag 
|| {};
  googletag.cmd = googletag.cmd || [];
  (function() {
    var gads = 
document.createElement("script");
    gads.async = true;
    gads.type = "text/JavaScript";

    var useSSL = "https:" == document.location.protocol;
    gads.src = (useSSL ? "https:" :
 "http:") +
    "//www.googletagservices.com/tag/js/gpt.js";
    var node 
=document.getElementsByTagName("script")[0];
    node.parentNode.insertBefore(gads, node);

   })();
</script>
</head>

<body>
<p>Peer39 categories are passing to the GPT Ad!</p>
<div
 id="banner1" style="width:300px; height:250px;"> </div>
<script type="text/JavaScript">

//PEER39 CODE - callback function which fire only when our segment response is load 
in the page
   function afterFinished_AID(){
//GOOGLE CODE - Implementing the AD

    googletag.cmd.push(function() {
         var adSlot1 = 
googletag.defineSlot('/6355419/Travel/Europe/France/Paris',
        [300, 250], "banner1");

//PEER39 CODE - p39_GPT_value() inserting the classification segments as values into 
the googletag object.
       adSlot1.addService(googletag.pubads().setTargeting("interests",
 
       p39_GPT_value()));
       googletag.enableServices();
    });
    googletag.cmd.push(function() {
 googletag.display('banner1');
    });
  }
</script>
</body>
</html>          

Live Example with the Google Publisher Tag (GPT)

Click here to see a typical implementation of the Peer39 tag with GPT. For a better understanding,  view the source code and observe all calls generated when the page loads.

This example meets all the requirements necessary for a successful implementation.

Passing a Custom Identifier to Peer39 Using the c_Query String Parameter

In some cases, you may want to pass to Peer39 a custom identifier for reporting purposes. A common use case is a Network client passing a site name or site ID. By passing the site name or ID, Peer39 can provide page-view volumes and category distribution insights, for example, by individual site in addition to overall Network reporting.

To pass a custom identifier, use the c_ parameter in the query string of the Peer39 JavaScript tag.

For example, the custom identifier SiteID1 is passed in the following example script as c_SiteID1.

<script id="peer39ScriptLoader" type="text/JavaScript" 
src="http://stags.peer39.net/AID/trg_AID.js?c_SiteID1"></script>            

Peer39 JavaScript Sandbox Testing

The Peer39 JavaScript Sandbox Tag enables your development resource to test the Peer39 service and review the results. Please contact the Peer39 Business Development team at Peer39info@sizmek.com for further details and to gain access to the Peer39 JavaScript Sandbox test tag for a limited time.

Additional Considerations when Testing and Implementing the Peer39 JavaScript Tag

  • You should implement the Peer39 JavaScript tag and callback function on every page across your sites.

  • Please ensure that the pages of your site or network are publicly accessible; Peer39 cannot classify pages or content that requires a login or registration to access.

  • Please let us know if your site includes strict traffic protocols that could block Peer39 content-analysis grabbers from accessing the site. In this case, we can provide the appropriate information to have Peer39 white-listed by your site.

  • Before live implementation, is highly recommended to test and implement in a staging or live testing environment that is representative of your live sites.

  • Peer39 can help QA and troubleshoot any issues with the JavaScript Tag implementation. When requesting QA and troubleshooting support, please provide a live page or test page where Peer39 is implemented.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments