This documentation covers the integration of Google Ad Exchange (AdX) with the Publisher Audience Limits (PAL) SDK for Connected TV (CTV) advertising simulation across different CTV providers.
The CTV Simulator now supports:
- Google AdX Integration: Server-side ad requests to Google's ad exchange
- Real GAM Endpoint: Direct integration with Google Ad Manager live endpoints
- PAL SDK Support: Privacy-focused audience limiting and verification
- Multi-CTV Provider Support: Roku, Samsung Tizen, LG webOS, Amazon Fire TV, Android TV, Apple TV
- Comprehensive CTV Parameters: All recommended programmatic CTV video parameters
- Real-time Testing: Mock and production-ready endpoints for development
- Server-side ad request processing
- OpenRTB 2.5 compliant requests
- Real GAM Endpoint Support: Direct calls to
pubads.g.doubleclick.net - Publisher ID and ad unit path configuration
- Real-time bid response simulation
- VAST XML ad creative delivery
- FailArmy CTV Integration: Pre-configured for FailArmy's CTV Android inventory
- Nonce generation for privacy protection
- Ad session verification
- CTV-specific player configuration
- OMID (Open Measurement Interface Definition) support
- Event tracking for compliance
- Roku: DVP player simulation with Roku-specific capabilities
- Samsung Tizen: Smart TV platform with enhanced codec support
- LG webOS: WebOS player with comprehensive DRM support
- Amazon Fire TV: Android-based platform with Fire TV optimizations
- Android TV: Google's TV platform with latest codec support
- Apple TV: iOS-based platform with FairPlay DRM
The integration now includes all recommended and required programmatic CTV parameters:
iu: Inventory unit (e.g.,/22106938864,22966701315/failarmy-auth-ctv-android)description_url: Content description URLtfcd: Tag For Child-Directed treatmentnpa: Non-Personalized Ads flagpp=CTV: Platform parameter for Connected TVgdfp_req=1: Google DFP request indicatoroutput=vast: VAST XML output formatenv=vp: Video player environmentimpl=s: Server-side implementationvad_type=linear: Linear video ad type
sz: Multiple video sizes (720p, 1080p, 4K)min_ad_duration/max_ad_duration: Ad duration limitsvideo_doc_id: Video document identifierapi: Supported API frameworks (VPAID 1.0/2.0, OMID 1.0, SIMID 1.0)protocol: VAST protocol versions (2.0-4.2)mime_type: Platform-specific MIME typesua: Platform-specific user agentsdt=3: Device type (Connected TV)
- Roku:
rdid(Roku Device ID) - Samsung:
tifa(TV Identifier for Advertising) - LG:
lgudid(LG Unique Device ID) - Fire TV:
amazon_aid(Amazon Advertising ID) - Android TV:
gaid(Google Advertising ID) - Apple TV:
idfa(Identifier for Advertisers)
gdpr/gdpr_consent: GDPR complianceus_privacy: CCPA complianceschain: Supply chain transparencyfpd: First-party datacontent_rating: Content rating (G, PG, PG-13, R, NC-17)live: Live content indicator
pal_nonce: PAL-generated noncepal_session_id: PAL session identifier
When "Use Real GAM Endpoint" is enabled, the system generates a comprehensive URL like:
https://pubads.g.doubleclick.net/gampad/live/ads?
iu=/22106938864,22966701315/failarmy-auth-ctv-android&
description_url=https://ctv-simulator.com&
url=https://ctv-simulator.com/content&
tfcd=0&npa=0&pp=CTV&gdfp_req=1&
unviewed_position_start=1&output=vast&env=vp&impl=s&
vad_type=linear&sz=1280x720|1920x1080|3840x2160&
correlator=1703123456789&nofb=1&
rdid=aaid_abc123456789&idtype=aaid&is_lat=0&
vid=content_abc123456&cmsid=123456&vpos=preroll&
plcmt=1&vpa=1&vpmute=0&
min_ad_duration=0&max_ad_duration=30000&
sid=sess_xyz789_1703123456&
omidpn=CTV-Simulator&omidpv=1.0.0&
us_privacy=1YN-&gdpr=1&
gdpr_consent=CPz_z_z_z_z_z_z_z_z_z_z_z_z_z_z_z&
tfua=0&ua=Roku%2FDVP-12.0&dt=3&make=Roku&model=Roku&
video_doc_id=video_abc123&video_duration=600&
api=1,2,7&protocol=2,3,5,6,7,8&
mime_type=video/mp4,video/webm&pos=1&
skippable=1&skip_delay=5&content_rating=G&
pal_nonce=pal_def456_1703123456&
pal_session_id=sess_ghi789_1703123456&
request_id=adx_req123_1703123456&
schain=1.0,1!ctv-simulator.com,ctv-simulator,1,...&
is_roku_tv=1&screen_width=1920&screen_height=1080&
screen_density=1.0&hdr_support=1&audio_channels=8&
hl=en&ad_type=video&videoad_start_delay=0&
frm=0&ga_fc=1&ga_cid=ga_client123456
This URL includes all 80+ CTV-specific parameters for optimal programmatic performance and compliance.
- ✅
iu- Ad unit path (FailArmy inventory) - ✅
description_url- Content description URL - ✅
url- Page URL where ad is displayed - ✅
correlator- Unique request identifier - ✅
sz- Supported video sizes (720p, 1080p, 4K)
- ✅
rdid+idtype- Platform-specific advertising IDs - ✅
is_lat- Limit Ad Tracking setting - ✅ Device markers (
is_roku_tv,is_android_tv, etc.) - ✅ Screen capabilities and HDR support
- ✅
vid- Video content identifier - ✅
cmsid- Content management system ID - ✅
vpos- Ad position (preroll/midroll/postroll) - ✅
plcmt- Placement type (in-stream) - ✅
vpa/vpmute- Auto-play and mute settings
- ✅
us_privacy- CCPA compliance string - ✅
gdpr+gdpr_consent- GDPR TCF v2.0 compliance - ✅
tfua- Tag for users under age of consent - ✅
omidpn+omidpv- Open Measurement integration
- ✅
pal_nonce- PAL-generated privacy nonce - ✅
pal_session_id- PAL session identifier - ✅ Real-time verification and event tracking
interface AdXConfig {
publisherId: string; // Google Publisher ID (pub-xxx)
adUnitPath: string; // Ad unit path (/networkcode/adunit)
networkCode: string; // Google Ad Manager network code
serviceAccountKey?: string; // Optional service account for authentication
enablePAL: boolean; // Enable PAL SDK integration
palConfig?: PALConfig; // PAL-specific configuration
}interface PALConfig {
descriptionUrl: string; // Content description URL
privacyPolicy: string; // Privacy policy URL
playerType: 'ctv'; // Player type (CTV)
playerName: string; // Player name
playerVersion: string; // Player version
videoWidth: number; // Video width (1920)
videoHeight: number; // Video height (1080)
videoTitle?: string; // Content title
videoDescription?: string; // Content description
videoDuration?: number; // Content duration in seconds
contentRating?: string; // Content rating (G, PG, PG-13, R, NC-17)
isLive?: boolean; // Live content flag
}POST /api/adx/pal/nonce
Content-Type: application/json
{
"descriptionUrl": "https://your-domain.com",
"privacyPolicy": "https://your-domain.com/privacy",
"playerType": "ctv",
"playerName": "CTV Player",
"playerVersion": "1.0.0",
"videoWidth": 1920,
"videoHeight": 1080
}Response:
{
"nonce": "pal_abc123_1234567890",
"adSessionId": "sess_def456_1234567890",
"videoSessionId": "vid_ghi789_1234567890",
"settings": {
"numRedirectsRemaining": 5,
"enabledEventTypes": ["start", "complete", "error"],
"nonceExpiry": 1234567890000
}
}POST /api/adx/pal/verify
Content-Type: application/json
{
"adSessionId": "sess_def456_1234567890",
"nonce": "pal_abc123_1234567890"
}Response:
{
"verified": true,
"adSessionId": "sess_def456_1234567890",
"impressionUrl": "https://googleads.g.doubleclick.net/..."
}POST /api/adx/request
Content-Type: application/json
{
"adxConfig": {
"publisherId": "pub-1234567890123456",
"adUnitPath": "/12345678/ctv_video_ads",
"networkCode": "12345678",
"enablePAL": true,
"palConfig": { ... }
},
"adRequest": {
"adUnitCode": "/12345678/ctv_video_ads",
"sizes": [[1920, 1080]],
"video": {
"playerSize": [[1920, 1080]],
"context": "instream",
"mimes": ["video/mp4", "video/webm"],
"protocols": [2, 3, 5, 6],
"minduration": 15,
"maxduration": 60
}
},
"ctvProvider": "roku"
}Response:
{
"id": "adx_abc123_1234567890",
"ads": [{
"requestId": "adx_abc123_1234567890",
"adUnitCode": "/12345678/ctv_video_ads",
"cpm": 5.25,
"currency": "USD",
"width": 1920,
"height": 1080,
"vastXml": "<?xml version=\"1.0\"?>...",
"creativeId": "adx_creative_def456",
"netRevenue": true,
"ttl": 300,
"meta": {
"advertiserDomains": ["example.com"],
"brandName": "Sample Brand",
"networkName": "Google AdX",
"mediaType": "video"
},
"pal": {
"verified": true,
"adSessionId": "sess_def456_1234567890",
"impressionUrl": "https://googleads.g.doubleclick.net/..."
}
}]
}GET /api/adx/providersResponse:
{
"roku": {
"name": "Roku",
"type": "roku",
"userAgent": "Roku/DVP-12.0 (12.0.0.4182-88)",
"capabilities": {
"drm": ["PlayReady", "Widevine"],
"video": {
"codecs": ["H.264", "H.265", "VP9"],
"profiles": ["Main", "High"],
"hdr": true,
"resolution": ["1920x1080", "3840x2160"]
},
"audio": {
"codecs": ["AAC", "AC3", "EAC3"],
"channels": [2, 6, 8]
}
}
}
}GET /api/adx/providers/roku- Open the AdX + PAL Tab: Click on the "AdX + PAL" tab in the left panel
- Configure AdX Settings:
- Enter your Google Publisher ID
- Set the network code
- Specify the ad unit path
- Configure PAL Settings:
- Enable PAL integration
- Set content URLs and metadata
- Configure video specifications
- Select CTV Provider: Choose from available CTV platforms
- Test Configuration: Click "Test AdX Request" to verify setup
import { PALEventTracker } from './utils/palService';
// Video playback events
PALEventTracker.onVideoStart();
PALEventTracker.onVideoEnd();
PALEventTracker.onPause();
PALEventTracker.onResume();
// Ad events
PALEventTracker.onAdBreakStart();
PALEventTracker.onAdStart('ad-id-123');
PALEventTracker.onAdEnd();
PALEventTracker.onAdBreakEnd();
// Error handling
PALEventTracker.onAdError(500, 'VAST parsing error');
// User interactions
PALEventTracker.onClick();
PALEventTracker.onVolumeChange(0.8);
PALEventTracker.onFullscreen(true);- Device Type: Roku streaming device
- User Agent:
Roku/DVP-12.0 (12.0.0.4182-88) - Video Codecs: H.264, H.265, VP9
- DRM: PlayReady, Widevine
- Resolutions: 1080p, 4K
- Device Type: Samsung Smart TV
- User Agent:
Mozilla/5.0 (SMART-TV; LINUX; Tizen 6.0) AppleWebKit/537.36 Samsung - Video Codecs: H.264, H.265, VP9
- DRM: PlayReady, Widevine
- Audio: Enhanced DTS support
- Device Type: LG Smart TV
- User Agent:
Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 LG - Video Codecs: H.264, H.265, VP9
- DRM: PlayReady, Widevine
- Features: WebOS optimizations
- Device Type: Fire TV Stick/Cube
- User Agent:
Mozilla/5.0 (Linux; Android 9; AFTMM) AppleWebKit/537.36 Fire TV - Video Codecs: H.264, H.265, VP9
- DRM: PlayReady, Widevine
- Platform: Android-based
- Device Type: Android TV device
- User Agent:
Mozilla/5.0 (Linux; Android 11; Android TV) AppleWebKit/537.36 - Video Codecs: H.264, H.265, VP9, AV1
- DRM: PlayReady, Widevine
- Features: Latest codec support
- Device Type: Apple TV device
- User Agent:
AppleCoreMedia/1.0.0 (Apple TV; U; CPU OS 15_0) - Video Codecs: H.264, H.265
- DRM: FairPlay
- Platform: iOS-based
Start the test server with AdX endpoints:
npm run test-serverThe server provides mock endpoints for:
- PAL nonce generation
- PAL session verification
- AdX ad requests
- CTV provider configurations
The test server provides realistic mock responses for development:
- Random CPM values ($1-$11)
- Sample VAST XML with tracking
- PAL verification simulation
- Provider-specific configurations
For production use:
- Replace mock endpoints with actual Google AdX URLs
- Configure service account authentication
- Implement real PAL SDK integration
- Set up proper error handling and logging
- Audience Limiting: Prevents over-targeting of users
- Privacy Protection: Reduces cross-site tracking
- Transparency: Provides verification mechanisms
- Industry Standards: Follows IAB and Google guidelines
- Supports GDPR consent strings
- Handles TCF (Transparency and Consent Framework) data
- Provides privacy policy integration
- Enables user consent management
-
PAL Nonce Generation Fails
- Verify description URL is accessible
- Check privacy policy URL validity
- Ensure player configuration is correct
-
AdX Requests Timeout
- Check network connectivity
- Verify publisher ID format
- Confirm ad unit path structure
-
CTV Provider Not Recognized
- Ensure provider exists in configuration
- Check user agent string format
- Verify capability specifications
Enable detailed logging in the browser console:
localStorage.setItem('adx_debug', 'true');
localStorage.setItem('pal_debug', 'true');- Google AdX Documentation
- PAL SDK Documentation
- OpenRTB 2.5 Specification
- VAST 4.0 Specification
- OMID SDK Documentation
To extend CTV provider support or enhance AdX integration:
- Add new provider configurations in
CTV_PROVIDERS - Update user agent strings and capabilities
- Test with the configuration panel
- Update documentation
For PAL SDK enhancements:
- Extend event tracking in
PALEventTracker - Add new signal types to
PALService - Update type definitions
- Test with different CTV platforms