Overview
The AppNexus add-on provides:- Automatic targeting - Helper methods for Xandr ads
- Impression tracking - Automatic ad impression tracking
- Contextual cohorts - Content-based targeting (v1.7.0+)
- Reaction segments - User cohort targeting
- Simple integration - Minimal code changes required
Installation
Add the AppNexus add-on to yourbuild.gradle.kts:
The AppNexus add-on does not include the Xandr SDK. You must add it separately.
Basic Usage
Adding Permutive Targeting
The add-on provides extension methods for adding Permutive targeting to Xandr ad views:Impression Tracking
Basic Impression Tracking
Track ad impressions automatically:Native Ads
Adding Targeting to Native Ads
What Gets Added to Ad Requests
When you calladdPermutiveTargeting(), the following targeting parameters are added:
1. Reaction Segments (User Cohorts)
User behavioral segments:2. Contextual Cohorts (v1.7.0+)
Content-based segments from the current page:- You’re using PageTracker with URLs
- Contextual data feature is enabled
- Content has been analyzed
Complete Integration Example
Contextual Cohorts
Enabling Contextual Cohorts
Contextual cohorts are automatically included (v1.7.0+) when:- Feature enabled - Contact your Customer Success Manager
- URLs provided - Use PageTracker with full URLs
- Content analyzed - Permutive has analyzed the content
Example with Contextual Cohorts
Use Cases
News/Content App
Video App
Ad Loading Best Practices
Load Ads After Page Tracking
For contextual cohorts, load ads after callingtrackPage():
Reuse Targeting for Multiple Ads
You can add targeting to multiple ad views:Troubleshooting
No Targeting Parameters in Ad Request
No Targeting Parameters in Ad Request
Problem: Permutive targeting not appearing in ad requests.Causes:
- Not calling
addPermutiveTargeting() - Permutive not initialized
- No cohorts available yet
- Verify you’re calling
addPermutiveTargeting()beforeloadAd() - Ensure Permutive is initialized before loading ads
- Check
permutive.currentCohorts()returns data - Enable debug logging:
permutive.setDeveloperMode(true)
Impressions Not Tracked
Impressions Not Tracked
Problem: Ad impressions not being tracked.Cause: Not calling
setPermutiveAdListener().Solution: Always set the Permutive ad listener:AdListener Conflicts
AdListener Conflicts
Problem: Your existing AdListener stops working.Cause: Permutive listener overriding yours.Solution: Pass your listener to
setPermutiveAdListener():Contextual Cohorts Not Included
Contextual Cohorts Not Included
Problem: Only user cohorts included, not contextual.Causes:
- Contextual feature not enabled
- Not providing URLs in
trackPage() - Using older add-on version (<1.7.0)
- Content not yet analyzed
- Contact Customer Success Manager to enable feature
- Always provide full URLs to
trackPage() - Update to
appnexus:1.7.0or later - Verify URLs are publicly accessible
Ads Not Serving
Ads Not Serving
Problem: Ads not displaying.This is not a Permutive SDK issue. Troubleshoot standard Xandr integration:
- Verify placement ID is correct
- Check ad inventory availability
- Verify Xandr SDK setup
- Review Xandr console
Best Practices
- Do
- Don't
- Call
addPermutiveTargeting()on all ad views - Call
setPermutiveAdListener()for impression tracking - Track pages with full URLs for contextual cohorts
- Load ads after calling
trackPage() - Pass existing AdListener to avoid conflicts
Version History
v1.7.0 (Latest)
- ✅ Automatic contextual cohort support
- ✅ Requires core 1.10.0+
- ✅ Enhanced ad targeting
v1.6.x
- Compatible with older core versions
- Basic targeting and impression tracking
Migration Notes
Upgrading to v1.7.0
No code changes required! Contextual cohorts are automatically included if:- Feature is enabled by Permutive
- You’re using PageTracker with URLs
Related Documentation
Contextual Data
Content-based targeting
Page Tracking
Track pages for contextual cohorts
Cohorts and Activations
Understanding segments
Installation
Add-on installation
Google Ad Manager
Alternative ad platform
Issues
Solve common issues
API Reference
For complete API documentation, see the Javadocs.Kotlin Extensions
AdView.addPermutiveTargeting(permutive: Permutive)- Add targeting to AdViewNativeAdRequest.addPermutiveTargeting(permutive: Permutive)- Add targeting to native adAdView.setPermutiveAdListener(permutive: Permutive)- Enable impression trackingAdView.setPermutiveAdListener(permutive: Permutive, listener: AdListener)- Enable tracking with custom listener
Java Utilities
AdViewUtils.addPermutiveTargeting(adView, permutive)- Add targetingAdViewUtils.addPermutiveTargeting(nativeAdRequest, permutive)- Add targeting to nativeAdViewUtils.setPermutiveAdListener(adView, permutive)- Enable impression trackingAdViewUtils.setPermutiveAdListener(adView, permutive, listener)- Enable tracking with custom listener
Getting Help
If you encounter issues with Xandr integration:- Check Troubleshooting Guide
- Verify AppNexus add-on is installed
- Ensure Xandr SDK is included separately
- Enable debug logging
- Contact your Customer Success Manager