Skip to main content
Contextual data enables real-time content-based segmentation without relying on historical user behavior. The SDK analyzes content users are viewing and generates contextual cohorts instantly.

How It Works

Implementation

Ad Targeting

Overview

In the Android SDK, contextual cohorts are generated in real-time when you track pages or videos with URLs. The SDK automatically includes these cohorts in ad requests alongside behavioral cohorts.

Requirements

  • Core SDK: 1.10.0 or higher
  • Google Ads Add-on: 2.2.0 or higher (for GAM integration)
  • AppNexus Add-on: 1.7.0 or higher (for Xandr integration)
  • Minimum Android API: 21 (Android 5.0)
  • Feature Enablement: Contact your Customer Success Manager
Feature Activation Required: Contextual content classification must be enabled by Permutive for your workspace. Please contact your Customer Success Manager if you’d like to use this feature.

How It Works

1

Track page/video with URL

Use PageTracker or MediaTracker with content URLs
2

Content analyzed

Permutive analyzes the content at the URL (page title, main text, keywords, IAB categories, sentiment)
3

Contextual cohorts generated

Content-based segments are created in real-time
4

Automatic activation

Contextual cohorts automatically included in ad requests

Implementation

Page Tracking with Contextual Data

Simply include URLs when tracking pages - contextual analysis happens automatically:

Video Tracking with Contextual Data

Contextual analysis also works with video content:

Accessing Contextual Cohorts

Contextual cohorts are automatically included in activations with special keys:

In Current Activations

In Ad Requests

Our add-on libraries automatically include contextual cohorts:

Xandr/AppNexus


Configuration

Contextual features are controlled by server-side configuration automatically applied to your SDK:

Configuration Flags

The SDK receives configuration that controls:
  • Segmentation enabled - Whether content classification is active
  • Event enrichment - Whether contextual data is added to events
  • Platform activations - Which ad platforms receive contextual cohorts

Checking Configuration Status

💡 Automatic Configuration Contextual features are enabled/disabled by your workspace configuration. Contact your Customer Success Manager to modify settings.

Performance Considerations

Content Analysis Timing

  • First analysis: May take 1-2 seconds for initial content fetch and analysis
  • Cached results: Subsequent views of the same URL use cached analysis
  • Background processing: Analysis happens asynchronously, doesn’t block UI
  • Network required: Content classification requires network connectivity

Impact on App Performance

Contextual analysis is designed to be lightweight:
  • Async processing - Doesn’t block main thread
  • Cached results - Same URLs reuse previous analysis
  • Efficient networking - Minimal data transfer
  • Graceful degradation - Falls back to behavioral targeting if unavailable

Best Practices for Performance


Privacy and Compliance

Privacy-Friendly Targeting

Data Sent for Analysis

When tracking a page with a URL:
  • URL - The page URL for content fetching
  • Title - Page title (if provided)
  • No PII - No personal information sent for classification
The URL should be publicly accessible for content analysis to work.

Opt-Out Handling

If users opt out of targeting:

Error Handling

Classification Failures

Contextual classification may fail if:
  • URL is not publicly accessible
  • Content is behind a paywall or login
  • Network connectivity issues
  • Server-side analysis errors
The SDK handles failures gracefully:

Debugging Classification

Enable debug logging to see classification status:

Use Cases

Content-Aligned Advertising

Video Ad Targeting

Contextual + Behavioral Targeting

Combine contextual and behavioral cohorts for powerful targeting:

Contextual vs. Behavioral Cohorts

In the SDK, contextual cohorts use activation keys dfp_contextual and appnexus_adserver_contextual, while behavioral cohorts use dfp and appnexus_adserver.

When to Use Each

Use Behavioral Cohorts When:
  • Building long-term audience segments
  • Retargeting campaigns
  • Personalization based on user history
  • Lookalike modeling
Use Contextual Cohorts When:
  • Real-time content alignment needed
  • Privacy regulations are strict
  • New users without history
  • Brand safety is critical
  • Cookie-less environment
Use Both When:
  • Maximum targeting precision needed
  • Combining user intent (contextual) with user interests (behavioral)
  • Premium inventory requires both signals

Troubleshooting

No Contextual Cohorts Appearing

Problem: dfp_contextual is empty or not present. Possible Causes & Solutions:
  1. Feature not enabled
    • Contact Customer Success Manager to enable
  2. SDK version too old
    • Update to Core 1.10.0+, Google Ads 2.2.0+, or AppNexus 1.7.0+
  3. No URL tracked
    • Ensure you’re using PageTracker or MediaTracker with URLs
  4. Classification in progress
    • First analysis may take 1-2 seconds
    • Check again after a moment
  5. URL not accessible
    • Ensure URL is publicly accessible
    • Remove authentication requirements for analysis
  6. Network issues
    • Check device connectivity
    • Look for network errors in logs

Classification Taking Too Long

Problem: Contextual cohorts not appearing before ads load. Solutions:
  • Start page tracking earlier in activity lifecycle
  • Consider delaying ad request slightly if contextual is critical
  • Use behavioral cohorts as fallback

Wrong Contextual Cohorts

Problem: Cohorts don’t match content. Possible Causes:
  • URL points to different content than displayed
  • Content changed since classification
  • Cache from previous analysis
Solutions:
  • Ensure URL matches actual content
  • Use unique URLs for different content
  • Wait for cache expiry or contact support to invalidate

Best Practices

✅ Do

  • Track pages/videos with URLs as early as possible
  • Use publicly accessible URLs
  • Ensure URLs are stable and won’t change
  • Test with debug logging enabled
  • Use unique URLs for different content
  • Combine with behavioral targeting for best results

❌ Don’t

  • Use authentication-protected URLs
  • Track pages without URLs (contextual won’t work)
  • Expect instant results (allow 1-2 seconds)
  • Rely solely on contextual for returning users
  • Use duplicate URLs for different content


API Reference

Contextual cohorts are accessed through standard SDK APIs:
  • Permutive.currentActivations["dfp_contextual"] - GAM contextual cohorts
  • Permutive.currentActivations["appnexus_adserver_contextual"] - Xandr contextual cohorts
  • PageTracker - Track pages with URLs for analysis
  • MediaTracker - Track videos with URLs for analysis
For complete API documentation, see the Javadocs.