Overview
Adrop SDK supports two types of targeting:- Audience Targeting: Target ads based on user attributes (gender, age, interests, etc.)
- Contextual Targeting: Target ads based on content or screen context
Audience Targeting
You can target ads based on user attributes.1. Create Targeting
First, create audience targeting in the Ad Control console.Create Targeting
Learn how to create audience targeting in the console
2. Set User ID
You must set the user identifier before rendering ads.Set the UID before entering the ad placement for targeting ads to work correctly.
3. Set User Properties
Setting user attributes enables more precise targeting.The
setProperty() method may have limited availability in Objective-C due to its Encodable parameter type. Use Swift for property configuration when possible.Built-in Properties
The SDK provides predefined keys for commonly used attributes.AdropKey
AdropValue
Predefined values for gender:Custom Properties
You can set additional properties registered in the console. All custom property keys are strings, and values support String, Int, Double, and Bool types.Constraints
Note the following constraints when setting properties:- Single values only: Arrays (
[String],[Int]) or dictionaries ([String: Any]) are not supported. - Supported types: Only String, Int, Double, and Bool are available.
- Key length: Up to 64 characters.
- Value length: String values up to 256 characters.
- Max properties: Up to 256 properties per user.
- Pre-registration required: Custom properties must be registered in the console first.
Event Tracking
Track user behavior events to build audiences based on user actions. UseAdropMetrics.sendEvent() to send events.
logEvent() is deprecated. Use sendEvent() instead.Sending Events
Multi-Item Events
For events involving multiple items (e.g., purchase, begin_checkout), pass an array of dictionaries under the"items" key.
Supported Event Examples
- Event name must be 1–64 characters.
- Parameter key must be 1–64 characters.
- String parameter values are limited to 1024 characters.
- Duplicate events with the same name and parameters are throttled within a 500ms window.
User Data Consent
You can control whether user data is sent to the server usinguserDataConsent. When set to false, property data is stored locally only, and events are not transmitted.
Contextual Targeting
You can target ads based on content or screen context.1. Create Targeting
First, create contextual targeting in the Ad Control console.Create Contextual Targeting
Learn how to create contextual targeting in the console
2. Set Value on Ad Placement
Pass the Context ID set in the console when loading ads.Banner Ads
Native Ads
Other Ad Formats
Context targeting applies only to banner and native ad requests that include a Context ID (banner and native ads in the Android and iOS SDKs, the Web SDK, and the REST API). Interstitial, rewarded, popup, and splash ads, as well as the Flutter and React Native SDKs, do not send a Context ID. If an ad product that contains these placements uses context targeting, campaigns that include context options are not shown in those placements, and context exclusions are not applied there.
Dynamic Context Setting
You can set context dynamically based on the screen or content.Context Setting in SwiftUI
Full Examples
Audience Targeting Full Example
Contextual Targeting Full Example
Best Practices
1. UID Setting Timing
Set the UID as soon as the user logs in.2. Maintain Property Consistency
Set user properties at app launch or whenever values change.3. Send Meaningful Events
Only send important user actions as events.4. Context ID Consistency
Context IDs must exactly match the values registered in the console.- Do not use commas (,) in Context IDs, because a comma separates multiple values both in the console and in an ad request. When requesting ads, pass the value exactly as entered in the console, without leading or trailing spaces.
- To match more than one context in a single request, pass a comma-separated value such as
hiking,outdoor. The first 5 IDs are used, and exclusion takes precedence over inclusion. See Passing Multiple Context IDs. - If you don’t pass a Context ID, or pass a value that isn’t registered in the console, no error occurs. Only campaigns with context targeting are excluded, and other ads can still be served.
Next Steps
Banner Ads
Apply targeting to banner ads
Native Ads
Apply targeting to native ads
Create Audience Targeting
Create audience targeting in the console
Create Contextual Targeting
Create contextual targeting in the console