Specifically, this is related to Facebook's Ad Targeting API.
At the top of the Ad Targeting API page, the page writes, without recommending other resources:
This document refers to a feature that was removed after Marketing API v2.0.
Issue:
I am trying to build an application that will use Facebook's location targeting feature, specifically I'm using their targeting by zip feature.
Facebook currently throws an error if an invalid zip(s) is/are submitted via POST request, yet it doesn't describe what the exact error is.
With that in mind, I was probing around their documentation looking for a validation API that I can call with the list of zip codes.
This is the closest link I can find: https://developers.facebook.com/docs/marketing-api/validation/v2.6
The validation API doesn't describe what I can use for validating location targets by zip.
Is there a separate API I can use?
Potential solutions at the moment
Use a currently-unknown validation API from FB to validate the list of zips
Make a batched call request to FB to determine the validity of the zip codes at run-time
Download all their zip codes and store it internally and use that instead.
Any suggestions/comments will be highly appreciated thanks!
You need to search zip code key on the base of user input through Facebook marketing API. After getting valid zip code key, you need to submitted it via POST request.
curl -G \
-d 'location_types=["zip"]' \
-d 'type=adgeolocation' \
-d 'q=9' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.6/search
Response Result
"data": [
{
"key": "US:90028",
"name": "90028",
"type": "zip",
"country_code": "US",
"country_name": "United States",
"region": "California",
"region_id": 3847,
"primary_city": "Los Angeles",
"primary_city_id": 2420379,
"supports_region": true,
"supports_city": true
},
]
searching of zip codes that are targetable on Facebook
curl \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={"geo_locations":{"zips":[{"key":"US:94304"},{"key":"US:00501"}]}}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.6/act_<AD_ACCOUNT_ID>/adsets
Targeting by zip codes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With