Google DoubleClick for Publishers (DFP)

In this article, we will cover strategies on how to integrate Sourcepoint CMP functionality with your organization's Google DoubleClick for Publishers (DFP). 


_sp_enable_dfp_personalized_ads

Sourcepoint sets a first-party cookie called _sp_enable_dfp_personalized_ads to help publishers manage their calls to the DFP ad server for personalized and non-personalized ads. The value is set to true if the user has consented to receive personalized ads and false if the user has rejected the delivery of personalized ads.

  Note: Be default, _sp_enable_dfp_personalized_ads is set to false by default the first time the CMP code loads for the end-user.

On the first pageview the _sp_enable_dfp_personalized_ads cookie will likely not be set in time for the first call to the ad server. For this call you can choose to either disable the initial load of the DFP ad calls and wait for the user's consent or rejection action, or you can proceed and have the DFP set NonPersonalizedAds flag set to 1 (true) in your GPT tags and allow non-personalized ads to show.


Not disabling initial load

If you do not want to disable the initial load of ads for the first pageview, then you can set the googletag.pubads().setRequestNonPersonalizedAds() flag to 0 or 1 depending on what the Sourcepoint _sp_enable_dfp_personalized_ads value is set to in your implementation.

See the code snippet below for an example. The example uses the jquery $.cookie() function to retrieve the cookie value.

<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'>
</script> <script> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; </script>
<script> googletag.cmd.push(function() { googletag.defineSlot('/44586335/example', [[88, 31], [728, 90]], 'div-gpt-ad-1536691535894-0').addService(googletag.pubads()); if($.cookie('_sp_enable_dfp_personalized_ads') === 'true') { googletag.pubads().setRequestNonPersonalizedAds(0); } else { googletag.pubads().setRequestNonPersonalizedAds(1); } googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script>

Use GPT disable load method

If you choose to disable for the first pageview, you should create a flag to be used in Sourcepoint's consent actions for DFP. Below is an example variable:

var dfp_inital_load_disabled = false;

A code example of a GPT tag setup that uses the disableInitialLoad() flag is below. The dfp_inital_load_disabled variable will be used in the CMP user interface and leveraged in the DoubleClick "Consent Action" field.

<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'>
</script> <script> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; var dfp_inital_load_disabled = false; </script> <script> googletag.cmd.push(function() { googletag.defineSlot('/44586335/example', [[88, 31], [728, 90]], 'div-gpt-ad-1536691535894-0').addService(googletag.pubads()); if (typeof $.cookie('_sp_enable_dfp_personalized_ads') === 'undefined') { //no cookie googletag.pubads().disableInitialLoad(); dfp_inital_load_disabled = true; } else { if($.cookie('_sp_enable_dfp_personalized_ads') === 'true') { googletag.pubads().setRequestNonPersonalizedAds(0); } else { googletag.pubads().setRequestNonPersonalizedAds(1); } } googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script>

The next step in using the disableInitialLoad() method is to setup the consent and reject actions in the UI to fire for the user based on whether they have consented to DFP personalized ads or rejected them.

From your Sourcepoint account, navigate to a vendor list for a regulatory regime (GDPR TCF, GDPR Standard, CCPA) and click Google Doubleclick on your vendor list. 

Screen_Shot_2022-01-11_at_11.12.13_AM.png

From the subsequent modal, select Consent Actions or Reject Actions, and follow the configuration steps below.

Screen_Shot_2022-01-11_at_11.13.35_AM.png


Consent action configuration

For the consent action, we are likely to want to only fire this if there was no cookie present when the page load and the initial ad load was disabled. Therefore, we will use the variable we set up as a flag to manage these conditions.

If the flag is true then we will set: googletag.pubads().setRequestNonPersonalizedAds(0) and then call the googletag.pubads().refresh() command. See the code example below to enter into the consent actions window.

if(window.dfp_inital_load_disabled){
   window.googletag.pubads().setRequestNonPersonalizedAds(0);
   window.googletag.pubads().refresh();
}

Screen_Shot_2022-01-11_at_1.12.40_PM.png


Reject action configuration

For the reject action setup, we will fire the googletag.pubads().setRequestNonPersonalizedAds(1) and then call the googletag.pubads().refresh() command

if(window.dfp_inital_load_disabled){
   window.googletag.pubads().setRequestNonPersonalizedAds(1);
   window.googletag.pubads().refresh();
}

Screen_Shot_2022-01-11_at_1.13.21_PM.png

Was this article helpful?
0 out of 0 found this helpful