LT.js Google Ad Manager Guide
OVERVIEW
Learn the best practices for incorporating Lightning Tag with Google Ad Manager, enabling you to push audiences, Panorama ID and Profiles IDs to Google.
The example below allows you to receive the Lotame audience matches for a user and pass those audiences to Google Ad Manager for targeting.
Note: If you are using an ad-server other than Google, simply replace any lines referencing googletag with references to your specific implementation.
In order to ensure the fastest audience targeting response, copy and paste the following into your page's <head> section. Make sure that Lightning Tag's onProfileReady callback returns before the googletag.enableServices() call ensures that your Lotame audiences are included in the call to Google.
Lotame recommends loading this directly on your page in the <head> section to best ensure that targeting calls will complete in time to include Lotame's audiences in your ad calls successfully. We recommend against loading through a tag manager such as Google Tag Manager (GTM).
If you must use a tag manager, use any priority or sequencing features available to have the Lotame Lightning Tag fire as early as possible. Also, include the below prefetch and preconnect calls in the <head> section of your page and not in the tag management code as this will speed up the loading of the Lightning Tag script to best ensure Lotame audiences are available to your ad calls.
<link rel="preconnect" href="https://tags.crwdcntrl.net">
<link rel="preconnect" href="https://bcp.crwdcntrl.net">
<link rel="preconnect" href="https://c.ltmsphrcl.net">
<link rel="dns-prefetch" href="https://tags.crwdcntrl.net">
<link rel="dns-prefetch" href="https://bcp.crwdcntrl.net">
<link rel="dns-prefetch" href="https://c.ltmsphrcl.net">
By default we send all audiences for your user to Google. If you would like to limit that number, see Limit Audiences.
To see the full feature set that the Lotame Lightning Tag offers, including passing in your own data fields for rule matching purposes, visit the Detailed Reference Guide. Also check out the Lightning Tag FAQ for answers to common questions. If you need any other assistance, please reach out to Lotame by submitting a Support ticket form through this link.
Push Audiences to Google
Before using this snippet, please replace the instances of <lotameClientId> with your Lotame account's client ID.
<head>
<link rel="preconnect" href="https://tags.crwdcntrl.net">
<link rel="preconnect" href="https://bcp.crwdcntrl.net">
<link rel="preconnect" href="https://c.ltmsphrcl.net">
<link rel="dns-prefetch" href="https://tags.crwdcntrl.net">
<link rel="dns-prefetch" href="https://bcp.crwdcntrl.net">
<link rel="dns-prefetch" href="https://c.ltmsphrcl.net">
<script>
! function() {
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var targetingKey = 'lotame';
var lotameClientId = '<lotameClientId>';
var audLocalStorageKey = 'lotame_' + lotameClientId + '_auds';
// Immediately get audiences from local storage and get them loaded
try {
var storedAuds = window.localStorage.getItem(audLocalStorageKey) || '';
if (storedAuds) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(targetingKey, storedAuds.split(','));
});
}
} catch(e) {
}
// Callback when targeting audience is ready to push latest audience data
var audienceReadyCallback = function (profile) {
// Get audiences as an array
var lotameAudiences = profile.getAudiences() || [];
// Set the new target audiences for call to Google
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(targetingKey, lotameAudiences);
});
};
// Lotame Config
var lotameTagInput = {
data: {},
config: {
clientId: Number(lotameClientId),
audienceLocalStorage: audLocalStorageKey,
onProfileReady: audienceReadyCallback
}
};
// Lotame initialization
var lotameConfig = lotameTagInput.config || {};
var namespace = window['lotame_' + lotameConfig.clientId] = {};
namespace.config = lotameConfig;
namespace.data = lotameTagInput.data || {};
namespace.cmd = namespace.cmd || [];
}();
</script>
<script async src="https://tags.crwdcntrl.net/lt/c/<lotameClientId>/lt.min.js"></script>
</head>
Note: You need to source the Javascript tag from Lotame's server, as shown above to ensure correct functionality. Our Javascript tags are hosted in AWS Cloudfront CDN to provide the lowest latency possible worldwide.
Push Audiences and Panorama ID to Google
Before using this snippet, please replace the instances of <lotameClientId> with your Lotame account's client ID. This example uses lotame as the Google audience targeting key and lpanoramaid as the key for the Lotame Panorama ID sent to Google.
<head>
<link rel="preconnect" href="https://tags.crwdcntrl.net">
<link rel="preconnect" href="https://bcp.crwdcntrl.net">
<link rel="preconnect" href="https://c.ltmsphrcl.net">
<link rel="dns-prefetch" href="https://tags.crwdcntrl.net">
<link rel="dns-prefetch" href="https://bcp.crwdcntrl.net">
<link rel="dns-prefetch" href="https://c.ltmsphrcl.net">
<script>
! function() {
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var audTargetingKey = 'lotame';
var panoramaIdTargetingKey = 'lpanoramaid';
var lotameClientId = '<lotameClientId>';
var audLocalStorageKey = 'lotame_' + lotameClientId + '_auds';
// Immediately load audiences and Panorama ID from local storage
try {
var storedAuds = window.localStorage.getItem(audLocalStorageKey) || '';
if (storedAuds) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(audTargetingKey, storedAuds.split(','));
});
}
var localStoragePanoramaID = window.localStorage.getItem('panoramaId') || '';
if (localStoragePanoramaID) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(panoramaIdTargetingKey, localStoragePanoramaID);
});
}
} catch(e) {
}
// Callback when targeting audience is ready to push latest audience data
var audienceReadyCallback = function (profile) {
// Get audiences as an array
var lotameAudiences = profile.getAudiences() || [];
// Set the new target audiences for call to Google
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(audTargetingKey, lotameAudiences);
});
// Get the PanoramaID to set at Google
var lotamePanoramaID = profile.getPanorama().getId() || '';
if (lotamePanoramaID) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(panoramaIdTargetingKey, lotamePanoramaID);
});
}
};
// Lotame Config
var lotameTagInput = {
data: {},
config: {
audienceLocalStorage: audLocalStorageKey,
onProfileReady: audienceReadyCallback
}
};
// Lotame initialization
var lotameConfig = lotameTagInput.config || {};
var namespace = window['lotame_' + lotameClientId] = {};
namespace.config = lotameConfig;
namespace.data = lotameTagInput.data || {};
namespace.cmd = namespace.cmd || [];
} ();
</script>
<script async src="https://tags.crwdcntrl.net/lt/c/<lotameClientId>/lt.min.js"></script>
</head>
Push Audiences and Profile Id to Google
Before using this snippet, please replace the instances of <lotameClientId> with your Lotame account's client ID. This example uses lotame as the Google audience targeting key and lpid as the key for the Lotame profile id sent to Google.
<head>
<link rel="preconnect" href="https://tags.crwdcntrl.net">
<link rel="preconnect" href="https://bcp.crwdcntrl.net">
<link rel="preconnect" href="https://c.ltmsphrcl.net">
<link rel="dns-prefetch" href="https://tags.crwdcntrl.net">
<link rel="dns-prefetch" href="https://bcp.crwdcntrl.net">
<link rel="dns-prefetch" href="https://c.ltmsphrcl.net">
<script>
! function() {
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var audTargetingKey = 'lotame';
var pidTargetingKey = 'lpid';
var lotameClientId = '<lotameClientId>';
var audLocalStorageKey = 'lotame_' + lotameClientId + '_auds';
// Immediately load audiences and id from local storage
try {
var storedAuds = window.localStorage.getItem(audLocalStorageKey) || '';
if (storedAuds) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(audTargetingKey, storedAuds.split(','));
});
}
var localStoragePid = window.localStorage.getItem('_cc_id') || '';
if (localStoragePid) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(pidTargetingKey, localStoragePid);
});
}
} catch(e) {
}
// Callback when targeting audience is ready to push latest audience data
var audienceReadyCallback = function (profile) {
// Get audiences as an array
var lotameAudiences = profile.getAudiences() || [];
// Set the new target audiences for call to Google
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(audTargetingKey, lotameAudiences);
});
var lotamePid = profile.getProfileId() || '';
if (lotamePid) {
googletag.cmd.push(function() {
window.googletag.pubads().setTargeting(pidTargetingKey, lotamePid);
});
}
};
// Lotame Config
var lotameTagInput = {
data: {},
config: {
audienceLocalStorage: audLocalStorageKey,
onProfileReady: audienceReadyCallback
}
};
// Lotame initialization
var lotameConfig = lotameTagInput.config || {};
var namespace = window['lotame_' + lotameClientId] = {};
namespace.config = lotameConfig;
namespace.data = lotameTagInput.data || {};
namespace.cmd = namespace.cmd || [];
} ();
</script>
<script async src="https://tags.crwdcntrl.net/lt/c/<lotameClientId>/lt.min.js"></script>
</head>
Content aside
Categories
- 3 yrs agoLast active
- 3229Views
- 1 Following