GAM Integration
Overview
Complete Example
<!DOCTYPE html>
<html>
<head>
<title>n360ortb GAM Integration</title>
<!-- Google Publisher Tag -->
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(function() {
// Define your ad slots
googletag.defineSlot(
'/12345678/homepage-leaderboard',
[[728, 90], [970, 250]],
'div-leaderboard'
).addService(googletag.pubads());
googletag.defineSlot(
'/12345678/sidebar-mpu',
[[300, 250], [300, 600]],
'div-sidebar'
).addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
// IMPORTANT: Disable initial load to wait for header bidding
googletag.pubads().disableInitialLoad();
});
</script>
<!-- n360ortb loader -->
<script>
!function(){if(!window.n360ortb){window.n360ortb={init:function(){e("init",arguments)},fetchBids:function(){e("fetchBids",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},que:[]};var n=document.createElement("script");n.async=!0,n.src="https://lib.nexx360.io/nexx360_ortb.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t)}function e(n,t){window.n360ortb.que.push([n,t])}}();
</script>
<script>
// Initialize n360ortb
n360ortb.init({
currency: 'EUR',
gdpr: {
cmpTimeout: 1000
}
});
// Fetch bids
n360ortb.fetchBids({
slots: [
{
tagId: 'homepage-leaderboard-tag',
divId: 'div-leaderboard',
sizes: [[728, 90], [970, 250]]
},
{
tagId: 'sidebar-mpu-tag',
divId: 'div-sidebar',
sizes: [[300, 250], [300, 600]]
}
]
}, function(bids) {
// Set bid targeting on GPT slots
n360ortb.setDisplayBids();
// Refresh ads to trigger the GAM auction
googletag.pubads().refresh();
});
</script>
</head>
<body>
<h1>My Website</h1>
<div id="div-leaderboard">
<script>
googletag.cmd.push(function() {
googletag.display('div-leaderboard');
});
</script>
</div>
<p>Page content here...</p>
<div id="div-sidebar">
<script>
googletag.cmd.push(function() {
googletag.display('div-sidebar');
});
</script>
</div>
</body>
</html>Targeting Keys
Key
Description
Example Value
Key Configuration Points
1. Disable Initial Load
2. Match divId to GPT Slot ID
3. Matching Sizes
Automatic Targeting Cleanup
Refreshing Specific Slots
Setup Requirements
Next Steps
Last updated
Was this helpful?