Get Contextual Segments
Contextual API
Get Contextual Segments
POST
Get Contextual Segments
Retrieve contextual cohort codes for a given URL and page properties. Returns cohort codes formatted for Google Ad Manager.
Request
Query Parameters
Your Permutive API key. This is the same API key used for your main Permutive SDK deployment.
Body Parameters
The URL to retrieve contextual cohorts for. This is typically the current page URL.
An object containing page properties used for contextual classification. This should match the structure of properties you track in Pageview events, but must exclude any user-related data.
Response
All contextual cohort codes for the page. This is the complete list of cohorts that matched.
An object mapping activation destination names to arrays of cohort code strings. Each key is an activation destination (e.g.,
target_dfp, appnexus_adserver) and the value is an array of cohort codes configured for that destination.An object containing content classification data, returned when a classification provider is enabled in the account. Includes classifications such as categories, keywords, entities, sentiment, emotion, and concepts.
Example Request
Example Response
Implementation Notes
Always include 'rts' in targeting
Always include 'rts' in targeting
When passing targeting values to your ad server, always append
rts to the array of cohort codes. This is required for proper targeting:Call early in page lifecycle
Call early in page lifecycle
Make the API call as early as possible when the page loads to ensure targeting is attached to the first ad call. We recommend placing the API call in the
<head> of your page.Use the same API key
Use the same API key
Use the same API key that you use for your main Permutive SDK deployment. This ensures cohorts are correctly associated with your workspace.
Related
Activating in Google Ad Manager
Full implementation guide with code samples for Google Ad Manager.
API Introduction
Overview of the Contextual API.