DoubleClick Ad Targeting

Skip to end of metadata
Go to start of metadata

Introduction

DoubleClick for Publishers (DFP) Small Business is a hosted ad serving solution by Google that helps you manage your online advertising business. DFP supports  custom targetingtarget ads based on a user's custom properties.

Gigya provides functionality for integrating DFP's ad targeting with user's identity information. This way you may target your ads based on your user's dynamic information, such as age, gender, relationship status, country, likes, etc. For example, you can set an ad to appear only for single men above the age of 30. This document provides a guide on how to integrate Gigya with DFP's ad targeting.

Solution Overview

The solution has two parts:

The ad targeting solution is based on the assumption that we have information about the user, gathered after the user log in / registers to the site through Gigya. 
As long as the user is not logged-in there is no ad targeting and the user will be presented with general not targeted ads. When the user logs-in through Gigya, we create a cookie for ad targeting, but the ad is not refreshed immediately. Only after refreshing the page the ad is refreshed and the user data is used in DFP's algorithm for selecting a new ad. Please note, that DFP's algorithm is likely to deliver a targeted  ad, but may also deliver a general not targeted ad. Please also note that the ad targeting cookie expires after a day.

Please create a test site in the Gigya admin console for integration testing (don't use your production site) and use a test list on the target integration platform. We are able to put integrations in "sample mode" for testing, which will restrict audiences to 10 sample accounts.

 

User Data for Ad Targeting

The user data that may be used for ad targeting is the info available in the User object.
If Gigya's Registration-as-a-Service (RaaS) package or Profile Management - IDS (IS) package is part of your site package, then the user data is the info returned by the accounts.getAccountInfo method. This includes identity data and site specific custom data.
To find out whether RaaS/IS package is part of your site package, or to activate RaaS/IS package, please contact your Gigya Account Manager or contact us by filling in a support form on our site.

Adding Gigya to a Web Page that Uses DFP

In this section we use an example to demonstrate integrating Gigya with DFP.
We take a simple web page that uses DFP to present an ad, and add Gigya code to it, thus targeting the ad dynamically based on the user's identity data.

A Simple Page that Uses DFP (Without Gigya)

Running Example

Example Code

<html>
<head>
<script type='text/javascript'>

	// Load DFP
    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);
    })();

   googletag.cmd.push(function () {
		// Ad definition  
		googletag.defineSlot('/34718213/Gigya_demo_ad', [300, 250], 'ad-div').addService(googletag.pubads()); 
		googletag.pubads().enableSingleRequest();
		googletag.enableServices();
    });
</script>
</head>
<body >
	<h2>DoubleClick Demo</h2>
	</br>
	<!-- Ad presentation -->
	Ad : 
	<div id='ad-div' style='width:300px; height:250px;'>
		<script type='text/javascript'>
		    googletag.cmd.push(function () { googletag.display('ad-div'); });
		</script>
	</div>
</body>
</html>

Adding the Gigya Code

Running Example

Example Code

<html>
<head>
	<!--  Step 1 - include Gigya JS libs -->
	<script src="http://cdn.gigya.com/JS/gigya.js?apiKey=2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N"></script>
	<script src="http://cdn.gigya.com/js/gigyatargetad.min.js"></script>
	
	<script type='text/javascript'>
		// Load DFP
	    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);
	    })();
	
		
	    googletag.cmd.push(function () {
			// Step 2 - wrap DFP method call with Gigya gigya.adTarget.attachGoogleTag method call
			var adTargetParams = {
				targetingMap: {
					// define targeting
	                'gender': 'user.gender',
	                'relation': 'user.relationshipStatus'
	            }
	        }
	
			adTargetParams.slot = googletag.defineSlot('/34718213/Gigya_demo_ad', [300, 250], 'ad-div').addService(googletag.pubads()); 
	
			// call method
			gigya.adTarget.attachGoogleTag(adTargetParams);  
	
			googletag.pubads().enableSingleRequest();
			googletag.enableServices();
	    });
	
		// Refresh the page.
		// NOTE: We do NOT recommend reloading pages after login. Ad networks forbid refreshing ads unless a certain
		// amount of time has passed or the user performed acions. This reload is only for demonstration purposes.
		function onLoginHandler(eventObj) {	
			location.reload(true); 
		}
	</script>
</head>

<body>
	<h2>DoubleClick Demo - With Gigya Integration</h2>

	<!-- Basic Social Login integration -->
	Please log in using Facebook:
	<div id="loginDiv"></div>
	<script type="text/javascript">
	    gigya.socialize.showLoginUI({ containerID:'loginDiv', enabledProviders:"facebook", extraFields:'relationshipStatus', showTermsLink:false, height:50, onLogin:onLoginHandler});
	</script>
	</br></br>

	<!-- Ad presentation -->
	Ad - targeted for dynamic user gender and relationship status (after social login):
	<div id='ad-div' style='width:300px; height:250px;'>
		<script type='text/javascript'>
		    googletag.cmd.push(function () { googletag.display('ad-div'); });
		</script>
	</div>
</body>
</html>

Code Explanation

Step 1

Include Gigya's JS libs: In addition to Gigya's standard gigya.js, you also need to include gigyatargetad.min.js, as shown in the example code:

<!--  Step 1 - include Gigya's JS libs : -->
<script src="http://cdn.gigya.com/JS/gigya.js?apiKey=YOUR-GIGYA-API-KEY"></script>
<script src="http://cdn.gigya.com/gs/js/gigyatargetad.min.js"></script>

Step 2

Wrap DFP's "googletag.defineSlot" method call with Gigya's "gigya.adTarget.attachGoogleTag" method call: Instead of a direct call to DFP's googletag.defineSlot method, we call Gigya's gigya.adTarget.attachGoogleTag method which wraps the DFP method and adds the targeting:

// Step 2 - wrap DFP's "googletag.defineSlot" method call with Gigya's "gigya.adTarget.attachGoogleTag" method call
var adTargetParams = { // define method parameters
            targetingMap: { // define targeting
                'gender': 'user.gender',
                'relation': 'user.relationshipStatus'
            }
        }
adTargetParams.slot = googletag.defineSlot('/34718213/Gigya_demo_ad', [300, 250], 'ad-div').addService(googletag.pubads()); // reference to DFP's "googletag.defineSlot" method  

gigya.adTarget.attachGoogleTag(adTargetParams);  // call method

gigya.adTarget.attachGoogleTag method parameters

RequiredNameTypeDescription
Yes targetingMapJSON ObjectThe object maps between a DFP ad targeting custom criteria and a Gigya user data field. 
By default the Gigya user data fields are fields of the User Object, e.g. user.country, user.age, etc.
If you set the  methodName parameter to  " accounts.getAccountInfo " (see below), then the  user data fields are the fields returned by the  accounts.getAccountInfo  method, e.g. profile.age, profile.gender, etc.
Yes slotmethod referenceReference to DFP's googletag.defineSlot method call.
No methodNamestringThe name of the Gigya method for retrieving user information. The possible values are:

Preliminary Step - Social Login Integration

To have information about the user, the user has to login to the site through Gigya. 

Notes:

  1. Whether you implement Social Login. Registration-as-a-Service (RaaS) or Profile Management - IDS (IS), the integration is the same. The only difference is the "methodName" parameter (see description above). If you are using the RaaS/IS package, set the "methodName" parameter to "accounts.getAccountInfo".
  2. In the code example we added Gigya's Login Plugin as a native Social Login implementation

    <!-- Step 3 - Basic Social Login integration -->Please Login using Facebook:
    <div id="loginDiv"></div>
    <script type="text/javascript">
       gigya.socialize.showLoginUI({ containerID:'loginDiv', enabledProviders:"facebook", extraFields:'relationshipStatus', showTermsLink:false, height:50  });
    </script>