Targeting
Target X ads by location, interest, Tailored Audience, age, gender and language, and search X's targeting values.
The targeting fields go on POST /v1/ads/create and land on the line item as X targeting criteria.
Targeting fields
| Field | X targeting | Values from |
|---|---|---|
countries | Location | ISO country codes |
regions, metros, cities, zips | Location | { "key": "..." } from targeting search, dimension=geo |
interests | Interest | { "id": "..." } from targeting search, dimension=interest |
audienceInclude, audienceExclude | Custom audience | The X custom audience id of a Tailored Audience |
ageMin, ageMax | Age | Rounded out to the narrowest X age range that covers them |
gender | Gender | male or female; all sends no gender criterion |
languages | Language | Language codes such as en; a region suffix (en_GB) is dropped |
The geo keys and interest ids are X's own targeting values, so a key from another platform does not work.
incomeTier, customLocations and behaviors are rejected. X removed behavior targeting from its Ads API.
Age ranges
X targets one age range from a fixed list. A range starts at 13, 18, 21, 25, 35 or 50, and ends at 24, 34, 49 or 54, or runs open-ended.
Zernio picks the narrowest one that covers ageMin and ageMax. So ageMin: 20, ageMax: 40 targets 18 to 49.
Find targeting values
GET /v1/ads/targeting/search with the xads accountId searches X's own catalog (Search ad targeting). It takes dimension=geo or dimension=interest.
On geo, geoType is country, region, metro_area, city or zip, and countryCode narrows the results to one country.
const { data: search } = await zernio.adtargeting.searchAdTargeting({
query: { accountId: '66b2e19d8c3f5a7e9d0b1c2d', q: 'Austin', dimension: 'geo', geoType: 'city', countryCode: 'US' }
});
const keys = search.results.map((result) => ({ key: result.id }));Response (200):
{
"results": [
{ "id": "3b77caf94bfc81fe", "name": "Austin", "type": "city", "countryCode": "US" }
]
}A geo result's id is the X targeting value: send it as key. A country result's id is the ISO code that countries takes.
An interest result carries the interest id, with its parent categories in path.
If it fails
| Error | Cause | Fix |
|---|---|---|
400 with code invalid_field_value, param: "targeting.languages" | A language X cannot target | Use one of the codes the message lists. |
400 with param: "dimension" | A search dimension other than geo or interest | Search geo or interest. |
400 on incomeTier, customLocations or behaviors | X has no slot for them | Remove the field. |
501 with code feature_not_available | targeting sent to PUT /v1/ads/{adId} | Create a new ad with the new targeting. |
Related
- Search ad targeting: every parameter of the search.
- Create a campaign: the request these fields go on.
- Tailored Audiences: build the audiences
audienceIncludetargets. - Limits & Errors: targeting X does not support.