Custom Targeting
The Targeting struct/property allows you to enrich ad requests with application and user targeting information. All properties are fully compatible with the OpenRTB v2.5 specification. Note that this configuration is global and applies to all ad units.
General Notes
Namespaces
Almost all classes listed in this guide are in the BoldwinSDK.Core.Common.Targeting namespace. The exception is the main facade class Boldwin from the BoldwinSDK.Core namespace, which is used to apply targeting configuration.
For all code snippets in this guide, include the following imports in your C# files:
Nullable Reference Types
The Boldwin SDK package is designed with Nullable reference types enabled:
If your project does not use nullable reference types, you can ignore the question mark (?) in property types such as string?, IEnumerable<string>?, and similar declarations.
Complete Sample
For a comprehensive example of targeting configuration, refer to the InitBoldwinAds.SetupBoldwinTargeting() method in the sample code.
This sample is also available for import through the Package Manager UI.
API Reference
Targeting
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
App |
App? |
Application-specific targeting information based on the OpenRTB 2.5 App object. | app |
User |
User? |
User-specific targeting information based on the OpenRTB 2.5 User object. | user |
Example:
Targeting targeting = new()
{
App = new()
{
Version = "1.0.0",
Name = "Example App",
},
User = new()
{
YearOfBirth = 1990,
Gender = "M",
},
};
App
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Unique app ID assigned by the exchange. | id |
Name |
string? |
Application name. | name |
Bundle |
string? |
Bundle or package name (e.g., iOS bundle ID, Android package name). | bundle |
Domain |
string? |
Top-level domain associated with the application. | domain |
StoreUrl |
string? |
Application store URL (App Store or Google Play). | storeurl |
Categories |
IEnumerable<string>? |
IAB content categories for the application. | cat |
SectionCategories |
IEnumerable<string>? |
IAB section-level categories for additional contextual detail. | sectioncat |
PageCategories |
IEnumerable<string>? |
IAB page-level categories for granular content categorization. | pagecat |
Version |
string? |
Application version string. | ver |
PrivacyPolicy |
int? |
Indicates whether the app has a privacy policy (1 = yes, 0 = no). | privacypolicy |
Paid |
int? |
Indicates whether the app is paid (1 = paid, 0 = free). | paid |
Keywords |
string? |
Comma-separated keywords describing the application content. | keywords |
Publisher |
Publisher? |
Publisher information (owner/distributor of the application). | publisher |
Content |
Content? |
Content details within the application. | content |
Ext |
ExtSlot |
Exchange-specific extensions or custom fields. | ext |
Example:
App app = new()
{
ID = "app-id-123",
Bundle = "com.example.app",
Version = "1.0.0",
Name = "Example App",
StoreUrl =
#if UNITY_IOS
"https://apps.apple.com/app/id123456789"
#else
"https://play.google.com/store/apps/details?id=com.example.app"
#endif
,
Domain = "example.com",
Paid = 0,
PrivacyPolicy = 1,
Keywords = "sample,app,testing",
Categories = new[]
{
"IAB1",
"IAB10",
},
SectionCategories = new[]
{
"IAB2",
"IAB11",
},
PageCategories = new[]
{
"IAB3",
"IAB12",
},
Publisher = new()
{
ID = "pub_001",
Name = "Example Publisher",
},
Content = new()
{
ID = "content_001",
Title = "Sample Title",
},
Ext = "{\"custom_app_key\": \"custom_app_value\"}",
};
User
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Exchange-specific unique user identifier. | id |
BuyerUid |
string? |
Buyer-specific user ID from the demand-side platform or advertiser. | buyeruid |
YearOfBirth |
int? |
User's year of birth for demographic targeting. | yob |
Gender |
string? |
User's gender ("M" = Male, "F" = Female, "O" = Other/Unknown). | gender |
Keywords |
string? |
Comma-separated keywords associated with the user for behavioral targeting. | keywords |
CustomData |
string? |
Custom data string for bidder or advertiser-specific information. | customdata |
Geo |
Geo? |
Geographic location information (derived from GPS, IP address, or user profile). | geo |
Data |
IEnumerable<Data>? |
Array of user data segments from third-party data providers. | data |
ExtendedIds |
IEnumerable<ExtendedId>? |
Array of extended user IDs for cross-platform identity resolution. | eids |
Ext |
ExtSlot |
Exchange-specific extensions or custom user fields. | ext |
Example:
User user = new()
{
ID = "user123",
BuyerUid = "buyer456",
YearOfBirth = 1990,
Gender = "M",
CustomData = "customUserData123",
Geo = new()
{
Lat = 40.7128,
Lon = -74.0060,
},
Keywords = "sample,keywords,data",
Data = new[]
{
new Data()
{
ID = "seg_a",
Name = "Sports",
Segment = new[]
{
new Segment()
{
ID = "seg_a",
Name = "Sports",
Value = "football",
},
},
},
},
ExtendedIds = new[]
{
new ExtendedId()
{
Source = "adserver.org",
UniqueIds = new UniqueId[]
{
new()
{
ID = "uid_123",
AType = 1,
},
new()
{
ID = "dev_456",
AType = 2,
},
},
},
},
Ext = "{\"user_attr\": \"premium\"}",
};
Content
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Unique identifier for the content. | id |
Episode |
int? |
Episode number (for episodic content). | episode |
Title |
string? |
Content title. | title |
Series |
string? |
Series name for episodic content. | series |
Season |
string? |
Season identifier for episodic content. | season |
Artist |
string? |
Artist credited with the content. | artist |
Genre |
string? |
Content genre. | genre |
Album |
string? |
Album name (for music content). | album |
ISRC |
string? |
International Standard Recording Code for music content. | isrc |
Producer |
ContentProducer? |
Content producer information. | producer |
URL |
string? |
Content URL (direct link or landing page). | url |
Categories |
IEnumerable<string>? |
IAB content categories. | cat |
ProductionQuality |
int? |
Production quality level (1 = Unknown, 2 = Professional, 3 = Prosumer, 4 = User Generated). | prodq |
Context |
int? |
Content context type (1 = Video, 2 = Game, 3 = Music, 4 = Application, 5 = Text, 6 = Other). | context |
ContentRating |
string? |
Content rating string. | contentrating |
UserRating |
string? |
User-provided rating of the content. | userrating |
QagMediaRating |
int? |
IAB QAG media rating (1 = All Audiences, 2 = Over 12, 3 = Mature). | qagmediarating |
Keywords |
string? |
Comma-separated keywords describing the content. | keywords |
LiveStream |
int? |
Indicates whether content is a live stream (1 = yes, 0 = no). | livestream |
SourceRelationship |
int? |
Relationship to source (0 = Unrelated, 1 = Direct, 2 = Syndicated). | sourcerel |
Length |
int? |
Content length in seconds. | len |
Language |
string? |
Content language (ISO 639-1 code). | language |
Embeddable |
int? |
Indicates whether content is embeddable (1 = yes, 0 = no). | embeddable |
Data |
IEnumerable<Data>? |
Additional content data segments. | data |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example:
Content content = new()
{
ID = "content_001",
Title = "Sample Title",
Series = "Sample Series",
Season = "Season 1",
Episode = 5,
Artist = "Sample Artist",
Genre = "Documentary",
Album = "Sample Album",
ISRC = "US-XXX-99-12345",
Producer = new ContentProducer()
{
ID = "producer_001",
Name = "Test Producer",
Categories = new[]
{
"IAB30",
"IAB31",
},
Domain = "producer.com",
Ext = "{\"producer_key\": \"value\"}",
},
URL = "https://example.com/content",
ProductionQuality = 2,
Context = 1,
ContentRating = "PG-13",
UserRating = "4.5",
QagMediaRating = 1,
Keywords = "documentary,science,space",
LiveStream = 0,
SourceRelationship = 1,
Length = 1800,
Language = "en",
Embeddable = 1,
Categories = new[]
{
"IAB1",
"IAB2",
},
Data = new[]
{
new Data()
{
ID = "seg_a",
Name = "Sports",
Segment = new[]
{
new Segment()
{
ID = "seg_a",
Name = "Sports",
Value = "football",
Ext = "{\"confidence\": \"0.9\"}",
},
},
Ext = "{\"provider_tier\": \"A\"}",
},
},
Ext = "{\"content_type\": \"video/mp4\"}",
};
Geo
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
Lat |
Double |
Latitude coordinate (-90.0 to +90.0, negative values indicate south). | lat |
Lon |
Double |
Longitude coordinate (-180.0 to +180.0, negative values indicate west). | lon |
Type |
int? |
Location data source (1 = GPS/Location Services, 2 = IP Address, 3 = User Provided). | type |
Accuracy |
int? |
Estimated location accuracy in meters. | accuracy |
LastFix |
int? |
Seconds since geolocation was last determined. | lastfix |
IpService |
int? |
IP geolocation service provider (1 = IP2Location, 2 = Neustar, 3 = MaxMind, 4 = NetAcuity). | ipservice |
Country |
string? |
Country code (ISO 3166-1 alpha-3). | country |
Region |
string? |
Region code (ISO 3166-2). | region |
RegionFips104 |
string? |
Region code (FIPS 10-4 standard). | regionfips104 |
Metro |
string? |
Nielsen Designated Market Area (DMA) code. | metro |
City |
string? |
City name. | city |
Zip |
string? |
Postal or ZIP code. | zip |
UtcOffset |
int? |
Local time offset from UTC in minutes. | utcoffset |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example:
Geo geo = new()
{
Lat = 40.7128,
Lon = -74.0060,
Type = 1,
Accuracy = 50,
LastFix = 300,
IpService = 3,
Country = "USA",
Region = "NY",
RegionFips104 = "US36",
Metro = "501",
City = "New York",
Zip = "10001",
UtcOffset = -300,
Ext = "{\"geo_note\": \"gps\"}",
};
ExtendedId
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
Source |
string? |
Source identifier for the external user ID provider. | source |
UniqueIds |
IEnumerable<UniqueId>? |
Array of unique identifier objects from the specified source. | uids |
Ext |
ExtSlot |
Additional attributes for the external user ID. | ext |
Example:
ExtendedId extId = new ()
{
Source = "adserver.org",
UniqueIds = new UniqueId[]
{
new()
{
ID = "uid_123",
AType = 1,
Ext = "{\"sample_uid_key_1\": \"sample_uid_value_2\"}",
},
new()
{
ID = "dev_456",
AType = 2,
Ext = "{\"sample_uid_key_2\": \"sample_uid_value_2\"}",
},
},
Ext = "{\"sample_eid_key\": \"sample_eid_value\"}",
};
UniqueId
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Cookie or platform-native identifier. | id |
AType |
int? |
User agent type identifier for cross-platform ID resolution. | atype |
Ext |
ExtSlot |
Additional attributes for the unique identifier. | ext |
Example:
UniqueId uniqueId = new()
{
ID = "uid_123",
AType = 1,
Ext = "{\"sample_uid_key_1\": \"sample_uid_value_2\"}",
};
ContentProducer
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Exchange-specific content producer identifier. | id |
Name |
string? |
Content producer name. | name |
Categories |
IEnumerable<string>? |
IAB content categories for the producer's typical content. | cat |
Domain |
string? |
Top-level domain associated with the content producer. | domain |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example:
ContentProducer producer = new ()
{
ID = "producer_001",
Name = "Test Producer",
Categories = new[]
{
"IAB30",
"IAB31",
},
Domain = "producer.com",
Ext = "{\"producer_key\": \"value\"}",
};
Publisher
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Exchange-specific publisher identifier. | id |
Name |
string? |
Publisher name. | name |
Categories |
IEnumerable<string>? |
IAB content categories describing the publisher. | cat |
Domain |
string? |
Top-level domain of the publisher. | domain |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example:
Publisher publisher = new()
{
ID = "pub_001",
Name = "Example Publisher",
Domain = "publisher.example",
Categories = new[]
{
"IAB20",
"IAB21",
},
Ext = "{\"pubKey\": \"pubValue\"}",
};
Data
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Exchange-specific data provider identifier. | id |
Name |
string? |
Data provider name. | name |
Segment |
IEnumerable<Segment>? |
Array of data segment objects containing targeting values. | segment |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example:
Data data = new ()
{
ID = "seg_a",
Name = "Sports",
Segment = new[]
{
new Segment()
{
ID = "seg_a",
Name = "Sports",
Value = "football",
Ext = "{\"confidence\": \"0.9\"}",
},
},
Ext = "{\"provider_tier\": \"A\"}",
};
Segment
| Property | Data Type | Description | OpenRTB Field |
|---|---|---|---|
ID |
string? |
Data segment identifier specific to the data provider. | id |
Name |
string? |
Data segment name. | name |
Value |
string? |
Data segment value. | value |
Ext |
ExtSlot |
Exchange-specific extensions. | ext |
Example: