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
| Key | Description | Value Type |
|---|---|---|
AdropKey.GENDER | Gender | AdropValue.AdropGender |
AdropKey.AGE | Age | Int |
AdropKey.BIRTH | Date of birth | String (YYYY, YYYYMM, YYYYMMDD) |
AdropValue
Predefined values for gender:| Value | Description |
|---|---|
AdropValue.AdropGender.MALE | Male |
AdropValue.AdropGender.FEMALE | Female |
AdropValue.AdropGender.OTHER | Other |
AdropValue.UNKNOWN | Unknown |
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 | Description | Common Parameters |
|---|---|---|
app_open | App opened | — |
sign_up | User signed up | method |
view_item | Viewed item | item_id, item_name, price |
add_to_cart | Added to cart | item_id, item_name, price, quantity |
add_to_wishlist | Added to wishlist | item_id, item_name, price |
begin_checkout | Began checkout | currency, items |
purchase | Purchase completed | tx_id, currency, items |
page_view | Page viewed | page_id, page_category |
click | Element clicked | element_id, element_type |
- 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
Interstitial Ads
Rewarded Ads
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.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