Tout SDK: Track Player Performance for DFP integration

This tutorial will show you how to track performance of the Tout player (ad impression. quartile events, etc) if you have integrated Tout into your website using DFP.  Note: If you have implemented Tout by putting the Tout embed code directly on your website, follow this tutorial.

 

1) Log into your DFP instance and edit the “Creative” you created on step 4 of this tutorial.

 

2) Add the following snippet at the top of the “Code Snippet” text box:

<script>
  (function(){
    var onToutTracking = function(event_name, properties){

      // TODO: Put your custom logic here, there are some examples below.  Please edit as needed.

      // **********************************************************************************************
      //
      //   Example: Console.log debugging
      //
      //   Warning: This is helpful for debugging, but you probably want to remove it when the creative is live
      //
      // **********************************************************************************************
      if(window.console &amp;&amp; window.console.log){
        console.log("onToutTracking", event_name, properties);
      }

      // **********************************************************************************************
      //
      //   Example: Google Analytics
      //
      //   Warning: You need to use "window.parent.ga" instead of just "ga"
      //   Reason: DFP executes this javascript inside of a "friendly iframe", so you need to use
      //     window.parent.ga to access the ga function on the parent page
      //
      // **********************************************************************************************
      if(typeof window.parent.ga !== "undefined"){
        window.parent.ga('send', 'event', 'Tout', event_name);
      }

      // **********************************************************************************************
      //
      //   Example: Fire a DFP VIEW_URL pixel on an ad_impression event
      //
      //   Warning: This macro might be undefined.  So please verify it works correctly given your DFP setup.
      //
      // **********************************************************************************************
      if(typeof "%%VIEW_URL_UNESC%%" !== "undefined"){
        if(event_name === "ad_impression"){
          // creating the image element and setting the src will fire the pixel
          var img = document.createElement("img");
          img.src = "%%VIEW_URL_UNESC%%";
        }
      }
    };

    // Attach your callback functions to the TOUT_TRACKING variable.
    // Warning: This is window.parent.TOUT_TRACKING not TOUT_TRACKING, because DFP executes this js
    //   inside a friendly iframe
    window.parent.TOUT_TRACKING = {
      product_initialized: onToutTracking,
      product_loaded: onToutTracking,
      ad_requested: onToutTracking,
      ad_loaded: onToutTracking,
      ad_started: onToutTracking,
      ad_impression: onToutTracking,
      ad_video_started: onToutTracking,
      ad_first_quartile: onToutTracking,
      ad_midpoint: onToutTracking,
      ad_third_quartile: onToutTracking,
      ad_completed: onToutTracking,
      ad_error: onToutTracking,
      tout_played: onToutTracking,
      tout_played_first_quartile: onToutTracking,
      tout_played_mid_point: onToutTracking,
      tout_played_third_quartile: onToutTracking,
      tout_played_complete: onToutTracking
    };
  })();
</script>

Screenshot 2016-06-14 11.34.09

 

3) Edit the “onToutTracking” function as needed. What is shown above are just examples, please work with you Developer to modify as needed.

 

4) Save the creative.

Posted in Uncategorized