This article will cover the following:
Use the Geo & Device Targeting API to programmatically configure country, region, city, and device-level targeting rules on offers — enabling automated traffic routing and compliance controls without touching the CAKE UI.
api_key parameter. Find yours under Setup → System Access → API Keys.Overview
CAKE's geo and device targeting system lets you control which traffic reaches an advertiser's offer based on the visitor's geographic location and device type. Targeting rules are applied at the offer level and evaluated in real time on every click, ensuring that only qualifying traffic is routed to the offer's destination URL.
Geo targeting can be scoped down to country, region (state/province), city, and postal code. Device targeting allows you to restrict or allow traffic from desktop browsers, mobile browsers, tablets, and specific operating systems. When a click doesn't match an offer's targeting rules, CAKE redirects it to a fallback URL or blocks it, depending on your network's configuration.
Manage targeting rules through the CAKE UI at Offers → Manage Offers → [Offer] → Targeting, or configure them programmatically via the API — useful for networks that manage large offer catalogs or need to sync targeting rules from an external data source.
Key Concepts
- Geo Targeting — A rule set applied to an offer that restricts or permits traffic based on the visitor's detected geographic location, evaluated against CAKE's GeoIP database on every click.
- Country — The top-level geographic targeting dimension. Specified by ISO 3166-1 alpha-2 country code (e.g.,
US,CA,GB). - Region — A sub-national geographic targeting dimension corresponding to a state, province, or territory within a country. Specified by region name or code.
- City — City-level targeting within a country and region. CAKE resolves city from the click IP via GeoIP lookup.
- DMA — Designated Market Area — a US-specific geographic grouping used for regional advertising targeting, corresponding to television market regions.
- Device Type — The class of device used to generate a click: Desktop, Mobile, Tablet, or Other. Detected from the User-Agent string on the click request.
- Operating System — The OS detected from the click User-Agent: Windows, macOS, iOS, Android, Linux, etc. Used for device-level targeting granularity.
- Targeting Mode — Controls whether the targeting rule is a whitelist (allow only matching traffic) or blacklist (block matching traffic). Configured per targeting dimension.
- Fallback URL — The redirect destination for clicks that don't match the offer's targeting criteria. Configured at the offer level and applied when a click fails targeting validation.
Available Actions
Get Offer Geo Targets
/api/2/offer_geo_targets.json| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your CAKE API key. |
| offer_id | integer | Yes | The CAKE offer ID to retrieve targeting rules for. |
Sample request
GET https://yourdomain.cakemarketing.com/api/2/offer_geo_targets.json?api_key=YOUR_API_KEY&offer_id=1042Sample response
{
"request_status": "Success",
"response": {
"offer_id": 1042,
"geo_targets": [
{ "country": "US", "region": "", "city": "", "targeting_mode": "whitelist" },
{ "country": "CA", "region": "", "city": "", "targeting_mode": "whitelist" }
]
}
}Update Offer Geo Targets
/api/2/update_offer_geo_targets.json| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your CAKE API key. |
| offer_id | integer | Yes | The CAKE offer ID to update targeting for. |
| countries | string | No | Comma-separated list of ISO 3166-1 alpha-2 country codes to target (e.g. US,CA,GB). |
| regions | string | No | Comma-separated region/state names or codes within the targeted countries. |
| cities | string | No | Comma-separated city names within the targeted regions. |
| targeting_mode | string | No | whitelist (allow listed locations only) or blacklist (block listed locations). Default: whitelist. |
Sample request
POST https://yourdomain.cakemarketing.com/api/2/update_offer_geo_targets.json
{
"api_key": "YOUR_API_KEY",
"offer_id": 1042,
"countries": "US,CA",
"targeting_mode": "whitelist"
}Sample response
{
"request_status": "Success",
"response": {
"offer_id": 1042,
"geo_targets_updated": true
}
}Get Device Targeting
/api/2/offer_device_targets.json| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your CAKE API key. |
| offer_id | integer | Yes | The CAKE offer ID to retrieve device targeting for. |
Sample request
GET https://yourdomain.cakemarketing.com/api/2/offer_device_targets.json?api_key=YOUR_API_KEY&offer_id=1042Sample response
{
"request_status": "Success",
"response": {
"offer_id": 1042,
"device_targets": [
{ "device_type": "mobile", "os": "iOS", "targeting_mode": "whitelist" },
{ "device_type": "mobile", "os": "Android", "targeting_mode": "whitelist" }
]
}
}Update Device Targeting
/api/2/update_offer_device_targets.json| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your CAKE API key. |
| offer_id | integer | Yes | The CAKE offer ID to update. |
| device_types | string | No | Comma-separated device types to target: desktop, mobile, tablet. |
| operating_systems | string | No | Comma-separated OS names: iOS, Android, Windows, macOS. |
| targeting_mode | string | No | whitelist or blacklist. Default: whitelist. |
Sample request
POST https://yourdomain.cakemarketing.com/api/2/update_offer_device_targets.json
{
"api_key": "YOUR_API_KEY",
"offer_id": 1042,
"device_types": "mobile",
"operating_systems": "iOS,Android",
"targeting_mode": "whitelist"
}Sample response
{
"request_status": "Success",
"response": {
"offer_id": 1042,
"device_targets_updated": true
}
}You may also be interested in:
If you have any questions, please reach out to your dedicated CAKE Client Success Manager/Account Manager or contact the CAKE Support Team at support@getCAKE.com.