The Google Ad Manager (GAM) integration is the most full-featured production adapter for the Prebid Sales Agent. It connects the Sales Agent to the GAM API (using the googleads 49.0.0 SDK), enabling AI buying agents to create orders, manage line items, upload creatives, set targeting, and pull performance reports — all through the standard Sales Agent tool interface.
The adapter is identified by adapter_name: "google_ad_manager" and is implemented as a multi-module package under src/adapters/gam/.
Before configuring the GAM integration, ensure you have:
The GAM adapter supports two authentication methods. Choose the one that best fits your deployment model.
Service account authentication is the recommended approach for server-to-server deployments. It does not require user interaction and credentials do not expire.
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
OAuth 2.0 is useful for development environments or when a service account is not available.
GAM_OAUTH_CLIENT_ID=your-client-id.apps.googleusercontent.com
GAM_OAUTH_CLIENT_SECRET=your-client-secret
| Variable | Required | Description |
|---|---|---|
GOOGLE_APPLICATION_CREDENTIALS |
Yes (Option 1) | Path to the GCP service account JSON key file |
GAM_OAUTH_CLIENT_ID |
Yes (Option 2) | OAuth 2.0 client ID from Google Cloud Console |
GAM_OAUTH_CLIENT_SECRET |
Yes (Option 2) | OAuth 2.0 client secret |
GCP_PROJECT_ID |
No | GCP project ID (required for some reporting features) |
http://your-host:8000/admin.The adapter configuration is stored in the adapter_config table with adapter_type set to "google_ad_manager".
The GAM adapter supports the following default media channels:
| Channel | Description |
|---|---|
display |
Standard banner and rich media display ads |
olv |
Online video (pre-roll, mid-roll, post-roll) |
social |
Social media inventory |
The GAM adapter declares the following capabilities via its AdapterCapabilities configuration:
| Capability | Supported | Notes |
|---|---|---|
| Inventory Sync | Yes | Automatic background synchronization of ad units and placements |
| Inventory Profiles | Yes | Reusable inventory configurations that products reference |
| Custom Targeting | Yes | Key-value targeting via GAM custom targeting keys |
| Geo Targeting | Yes | Full geographic targeting including countries, regions, metros, and postal codes |
| Dynamic Products | Yes | Products that dynamically reference GAM inventory |
| All Pricing Models | Yes | CPM, CPC, CPD, and other GAM-supported pricing models |
| Webhooks | No | Use polling-based delivery reporting instead |
| Real-Time Reporting | No | Reporting pulled on demand via the GAM Reporting API |
The GAM adapter keeps the Sales Agent’s inventory data synchronized with your GAM network through background sync operations.
BackgroundSync operation periodically pulls ad units, placements, and targeting keys from GAM.When an AI buying agent calls create_media_buy, the GAM adapter:
The upload_creatives operation handles creative asset management:
sync_creatives tool.AssignCreatives.The GAM adapter supports multiple targeting dimensions:
The adapter exposes these through the get_targeting_capabilities() method, which returns a TargetingCapabilities instance describing all supported targeting dimensions.
The GAM adapter pulls delivery and performance metrics through the GAM Reporting API:
GetPerformanceReport operation fetches impressions, clicks, revenue, and other metrics.get_media_buy_delivery tool surfaces these metrics to AI buying agents.The adapter manages order and line item lifecycle transitions:
The GAM adapter is organized into specialized manager modules, each handling a distinct area of GAM API interaction:
| Module | File | Responsibility |
|---|---|---|
| Inventory Manager | inventory.py |
Ad unit and placement sync, inventory queries |
| Orders Manager | orders.py |
Order and line item CRUD, status transitions |
| Creatives Manager | creatives.py |
Creative upload, assignment, approval tracking |
| Targeting Manager | targeting.py |
Geographic, custom, and audience targeting |
| Reporting Manager | reporting.py |
Performance report generation and parsing |
| Sync Manager | sync.py |
Background synchronization orchestration |
| Workflow Manager | workflow.py |
Order approval and lifecycle management |
The GAM adapter implements robust error handling for API interactions:
AdCPAdapterError hierarchy.Publishers can configure naming templates that control how GAM orders and line items are named. These are set on the tenant configuration:
order_name_template — Template for GAM order names (e.g., "{advertiser} - {product} - {date}")line_item_name_template — Template for GAM line item namesTemplates support variable substitution with fields from the media buy, product, and principal. The Naming Agent (AI) can also generate names from briefs when templates are not sufficient.
Inventory profiles are reusable GAM inventory configurations that products can reference. They allow publishers to define named collections of ad units, placements, and targeting criteria that can be shared across multiple products.
| Error | Cause | Resolution |
|---|---|---|
AuthenticationError |
Invalid or expired credentials | Verify GOOGLE_APPLICATION_CREDENTIALS path or refresh OAuth tokens |
PermissionDenied |
Service account lacks GAM API access | Add the service account email in GAM Admin > API access |
QuotaExceeded |
GAM API rate limit hit | The adapter retries automatically; reduce sync frequency if persistent |
NetworkNotFound |
Incorrect GAM network code | Verify the network code in Admin UI adapter config |
InvalidCreativeSize |
Creative dimensions do not match line item | Ensure creative assets match the sizes defined in the product |
GAM enforces API request quotas per network. If you encounter persistent quota errors:
get_media_buy_delivery in tight loops — use reasonable polling intervals.If authentication fails after initial setup:
GOOGLE_APPLICATION_CREDENTIALS and has not been revoked.