Google Secure Signals for Publishers

The Google Secure Signals integration (previously known as Google Encrypted Signals) allows publishers who are working with GPT (Google Publisher Tags) to share Google-permissioned envelopes or LiveRamp’s Identity Envelope directly with bidders that the publishers choose to work with. The Google-permissioned envelope allows you to share RampIDs and RideAlong UIDs while staying within the character limits set by Google.

Envelopes will only be shared at the publisher’s explicit instruction and only with bidders the publisher has allowed to receive the envelope. This integration also supports Google Supply-Side Platforms allowing you to participate into Google's ecosystem.

Add Secure Signals Integration in Console

To enable Secure Signals, you must log in to Console and integrate an ATS configuration with Secure Signals.

  1. Go to ATS > Web and select an ATS configuration.
  2. Select Integrations and click Create New.
  3. Select Google Secure Signals.
  4. Click Publish.

Make Sure Secure Signals are Properly Shared

For your GAM (Google Ad Manager) account to be eligible for receiving secure signals, you must make sure secure signals are properly shared with third-party bidders on your GAM account. See Google’s article Share secure signals with bidders to learn all the required steps.

How to Work with Secure Signals and ATS API

1. Host a script with LiveRamp's unique ID
To share secure signals, such as LiveRamp’s Identity Envelope or Google envelope, you must host a script as specified by Google. The hosted script registers itself with GPT using our unique ID 'liveramp.com' (provided by Google Ad Manager).

You must paste the code snippet below into your page. The getEnvelopeObjectFromStorage function will first check the presence of the _lr_google_env. If the Google envelope is not present, the function will check the presence of an identity envelope _lr_env.

This getEnvelopeObjectFromStorage function will be attached to the ATS object on the window (window.ats.getEnvelopeObjectFromStorage()).

At the end of this step, you need to export a createESPTag function which will use the window.ats.getEnvelopeObjectFromStorage() function to get the envelope (\_lr_google_env or \_lr_env). If an envelope is present, it will be sent to Secure Signals.

function getItem(name) {
  if (localStorage.hasOwnProperty(name)) {
    return localStorage.getItem(name);
  }
}

function getCookie(cname) {
  const name = cname + '=';
  const attr = document.cookie.split(';');

  // Loop through the cookies and return the cookie value if it finds the cookie name
  for (let i = 0; i < attr.length; i++) {
    const c = attr[i].trim();
    // If the name is the cookie string at position 0, we found the cookie and return the cookie value
    if (c.indexOf(name) === 0) return decodeURIComponent(c.substring(name.length, c.length));
  }

  // If we get to this point, that means the cookie wasn't found and we return an empty string.
  return '';
}

function getEnvelopeObjectFromStorage() {
  let rawGoogleEnvelope = getItem('_lr_google_env') || getCookie('_lr_google_env');
if(rawGoogleEnvelope) {
	return JSON.parse(window.atob(rawGoogleEnvelope));
}
let rawLiveRampEnvelope = getItem('_lr_env') || getCookie('_lr_env');
if(rawLiveRampEnvelope) {
	return JSON.parse(window.atob(rawLiveRampEnvelope))
}
  return undefined;
}

window['ats'] = {}
window.ats.getEnvelopeObjectFromStorage = getEnvelopeObjectFromStorage

export function createESPTag() {
let envelopeObject = window.ats.getEnvelopeObjectFromStorage();
 
 if (envelopeObject && envelopeObject.envelope) {
   console.log('Inserting ESP script.');
  window.googletag =
    window.googletag || { secureSignalProviders: [], cmd: [] };
  window.googletag.secureSignalProviders.push({
    id: 'liveramp.com',
    collectorFunction: () => { return Promise.resolve(envelopeObject.envelope);
}
  });
 }
}


2. Implement a retrieve envelope function on every page
For the hosted script to retrieve LiveRamp’s Identity Envelopes you will need to implement a retrieve envelope function and expose it where you are resolving users to envelopes, preferably on every page.

The hosted script should be able to make a call to window.ats.retrieveEnvelope() and receive a JSON object like the following:
{"envelope":"AtkoTqF8plPFYr2r2QgpbhKhY_XWhJrmI0gSSTulk24dzDKTlNOf4A"}.

Make sure to have try-catch blocks in your window.ats.retrieveEnvelope() function in order to prevent any exception occurring in the createESPTag() function.

GPT will call your window.ats.retrieveEnvelope() function when required and LiveRamp Identity Envelope will be pushed to GPT and then be included in RTB (real-time bidding) requests within Google’s ad exchange.

Learn More

For more information on Secure Signals and ATS, see our FAQ.