How can I get Facebook Reach estimate programmatically and do I need to pay for an ad or have a funding source associated with my ad account to make the call to the reach estimate end point?
-
1This question appears to be off-topic because it is not programming related – Björn Kaiser Jul 16 '14 at 13:43
-
@BjörnKaiser This question absolutely is about programming and in fact it even contains the word "programmatically!" Please correct your classification of this question, thank you! – Erick Brown Aug 21 '19 at 19:35
1 Answers
You must use a Facebook application that is white listed for Ads API access, that is the only requirement that I know you have to have. I'm not sure if this is required or not, but you MAY have to have a funding source attached to the ad account before making this call, but I'm not 100% certain of that, I do know it's required to publish an ad which makes sense. To answer your question: Yes, actually you can utilize the reach estimate end point without creating an ad campaign provided the prerequisites are met. All you would need to do is submit targeting specs to the end point and you ought to see values returned. Reach Estimate Documentation Check that link for details on making the call to that end point. Another consideration is this end point is also accessible at the ad group level as well as for provided bid levels, each of which results in a slightly different call.
In the case of using reach estimate at the campaign level you could make a call to https://graph.facebook.com/act_AdAccountId/reachestimate?currency=US&access_token=[token generated that uses a white listed app]&targeting_sepc=[JSON Deserialized from whatever class you use to hold targeting data]
IE:
targeting_spec={"age_min":25,"geo_locations":{"cities":[{"key":2430536}]}}
Of course this would be URL encoded so it winds up looking more like this:
targeting_spec=%7B%22age_min%22%3A25%2C%22geo_locations%22%3A%7B%22cities%22%3A%5B%7B%22key%22%3A2430536%7D%5D%7D%7D
Note the 'geo_locations' field is a fairly new part of targeting specs and you'll want to provide Facebook with the key of a given city. In other words you'll want to look up the values you want to include in the targeting spec field.
And the data returned is JSON. In the example above the returned JSON would look like so:
{
"users": 1460000,
"bid_estimations": [{
"unsupported": false,
"location": 3,
"cpa_min": 237,
"cpa_median": 375,
"cpa_max": 521,
"cpc_min": 44,
"cpc_median": 63,
"cpc_max": 84,
"cpm_min": 42,
"cpm_median": 207,
"cpm_max": 352
}],
"estimate_ready": true,
"data": {
"users": 1460000,
"bid_estimations": [{
"unsupported": false,
"location": 3,
"cpa_min": 237,
"cpa_median": 375,
"cpa_max": 521,
"cpc_min": 44,
"cpc_median": 63,
"cpc_max": 84,
"cpm_min": 42,
"cpm_median": 207,
"cpm_max": 352
}],
"estimate_ready": true
}
}
I know I've given you more information that you've asked, but I'm hoping this helps explain what to expect when you're able to make a successful call.
Hope this helps answer the question as well as help you with what to expect as a return value from making a successful call.
-Erick

- 618
- 11
- 22
-
1
-
SuperCat: No problem at all, happy to help. :) If you don't mind and if possible can you up vote the answer, please? :) And yeah, interesting idea actually... Have some fields to allow users to input values and get the reach estimate data back and display it in a friendly way. Not a bad idea if I do say so myself. :) – Erick Brown Jul 17 '14 at 18:49
-
1Can't up vote at mo unfortunately, hopefully someone else will find this really useful too. Yes a facebook reach page could be very popular. Cheers – SuperCat Jul 19 '14 at 08:50