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:

  1. Loads the n360ortb library inside the creative iframe

  2. Fetches bids directly from Nexx360

  3. 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:

Mode
Description
Resize Method

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)

circle-check

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

  1. Go to Delivery > Creatives in GAM

  2. Click New creative > Third party

  3. Set the creative size to match your ad size (e.g., 300x250)

circle-exclamation

Step 2: Add the Creative Code

Replace YOUR_TAG_ID with your actual Nexx360 tag ID configured in the console.

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

Macro
Description

%%GDPR%%

Returns 1 if GDPR applies, 0 if not

%%GDPR_CONSENT_755%%

Returns the TC string (755 = Nexx360 vendor ID)

Creative Code with GDPR

circle-info

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:

Context
Detection
Behavior

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

Issue
Cause
Solution

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

Use Case
Recommended Approach

Full header bidding with targeting

Backfill creative without page changes

This approach (Integration in GAM as Creative)

Testing n360ortb without page modifications

This approach

Production with price competition

Next Steps

Last updated

Was this helpful?