Integration in GAM as Creative
This page explains how to run n360ortb directly inside a GAM creative to fetch and render bids. This approach is useful when you want GAM to handle the ad delivery without adding header bidding code to the publisher page.
Overview
Instead of running n360ortb on the publisher page, you can configure a GAM creative that:
Loads the n360ortb library inside the creative iframe
Fetches bids directly from Nexx360
Renders the winning ad in place
This is sometimes called a "GPT Test Tag" setup and is useful for:
Testing the integration without modifying publisher pages
Running Nexx360 as a backfill creative in GAM
Simplified setups where the publisher doesn't need on-page targeting
Iframe Modes
GAM renders creatives inside iframes. Understanding the two iframe modes is important for proper ad rendering:
Friendly Iframe
Same-origin iframe, creative can access window.frameElement
Direct resize via frameElement.style
SafeFrame
Cross-origin iframe for security isolation
$sf.ext.expand() API (requires correct creative size in GAM)
Recommendation: Use Friendly Iframe mode for reliable iframe resizing.
Configuring Iframe Mode on Publisher Page
To disable SafeFrame and enable friendly iframe mode, the publisher should add:
Creative Setup in GAM
Step 1: Create a Third-Party Creative
Go to Delivery > Creatives in GAM
Click New creative > Third party
Set the creative size to match your ad size (e.g., 300x250)
Important: Set the creative size in GAM to match the ad size (300x250, 728x90, etc.). If set to 1x1, the iframe will be 1x1 regardless of resize attempts.
Step 2: Add the Creative Code
Replace YOUR_TAG_ID with your actual Nexx360 tag ID configured in the console.
GDPR Consent Handling
When running inside a GAM creative iframe, the TCF CMP on the publisher page may not be accessible (especially in SafeFrame mode). Use GAM macros to pass GDPR consent data directly.
GAM GDPR Macros
%%GDPR%%
Returns 1 if GDPR applies, 0 if not
%%GDPR_CONSENT_755%%
Returns the TC string (755 = Nexx360 vendor ID)
Creative Code with GDPR
When gdpr.applies and gdpr.consent are provided directly, n360ortb skips CMP detection and uses the provided values immediately.
Step 3: Target the Creative
Create a line item that targets this creative to the appropriate ad units and inventory.
How renderAd() Works
The renderAd() function automatically detects the iframe context and uses the appropriate rendering method:
SafeFrame
window.$sf?.ext exists
Calls $sf.ext.expand(), then document.write(adm)
Friendly iframe
window.frameElement accessible
Resizes parent iframe directly, renders into container
Cross-origin iframe
Neither of above
Sends postMessage resize request to parent
Troubleshooting
Ad renders in 1x1 iframe
Creative size in GAM is 1x1
Set creative size to 300x250 (or actual ad size) in GAM
SafeFrame doesn't expand
SafeFrame expand is for expandable ads only
Use correct size in GAM, or use Friendly Iframe mode
Can't resize iframe
SafeFrame blocks frameElement access
Disable SafeFrame with setForceSafeFrame(false)
Ad doesn't render
No bids returned
Check tagId configuration and network requests in dev tools
CORS errors
Cross-origin restrictions
Ensure you're loading from https://lib.nexx360.io/
Debug Mode
To troubleshoot issues, enable debug mode:
Or add ?n360debug=true to the publisher page URL to see console logs.
Complete Example
Here's a full example of a publisher page with a GAM slot configured for friendly iframe mode:
When to Use This Approach
Full header bidding with targeting
Standard GAM Integration
Backfill creative without page changes
This approach (Integration in GAM as Creative)
Testing n360ortb without page modifications
This approach
Production with price competition
Standard GAM Integration
Next Steps
GAM Integration - Standard header bidding integration
Connect your GAM Account - Initial setup
API Reference - Full API documentation
Last updated
Was this helpful?