Overview
This guide walks you through activating Permutive contextual cohorts in Google Ad Manager (GAM) for ad targeting. The implementation calls the Contextual API directly (without the Permutive SDK) and passes the returned cohort codes to GAM as key-value targeting. This approach is designed for environments where user consent is not available, allowing you to target ads based on page content without processing user data.Prerequisites:
- A Permutive workspace API key
- Admin access to Google Ad Manager to configure key-values
- Contextual Cohorts created and activated in the Permutive Dashboard
Configure GAM Key-Values
Before implementing the code, configure a key-value in Google Ad Manager.1
Navigate to Key-Values
In Google Ad Manager, navigate to Inventory > Key-Values and click New key-value.
2
Create the key
Configure the key with these settings:
- Name:
prmtvctx - Display name: Permutive Contextual
- Value type: Predefined
- Report on values: Include values in reporting
Implementation
Choose the implementation for your platform. Each example calls the Contextual API/segment endpoint and passes the returned cohort codes to GAM.
- Web
- iOS
- Android
Add this script to the The
<head> of your page, as early as possible to ensure targeting is attached to the first ad call. You may need to customize this snippet to work with your setup.Replace the following placeholders:$API_KEY— the same API key you use in your main Permutive deployment$PAGE_PROPERTIES— the same page properties object you pass towindow.permutive.addon('web', { page: {...} }), excluding any user-related properties
enrichClient function adds client properties (URL, referrer, user agent, domain, title) to the payload, enabling additional targeting options.Testing
After implementing the code, verify that contextual targeting is working correctly:1
Test in staging
Deploy the implementation in a staging or test environment first. Load a page with the script and check your browser’s network tab to confirm the Contextual API request completes successfully and returns cohort codes.
2
Verify GAM targeting
Inspect the ad request in your browser’s developer tools to confirm that the
prmtvctx key-value is present with the expected cohort codes.3
Share testing link
Share a testing link with Technical Services so we can help validate the deployment before releasing to production.
Troubleshooting
API returns empty cohorts
API returns empty cohorts
Verify that:
- You are using the correct API key
- Contextual cohorts have been created and activated in the Permutive dashboard
- The URL being passed matches content that has been classified
Targeting not appearing in ad requests
Targeting not appearing in ad requests
Check that:
- The API call completes before the ad request is made
- The key-value
prmtvctxis correctly configured in your ad server
CORS errors (Web)
CORS errors (Web)
The Permutive API supports CORS for web implementations. If you encounter CORS errors, verify that your domain is correctly configured in your Permutive workspace settings.
Next Steps
Contextual API Reference
Full API documentation for the Contextual API
Creating Contextual Cohorts
Build audience segments based on page content
Back to Contextual Cohorts
Return to product overview