facebook marketing insights empty response - facebook

I am trying really hard to get insights for an ad account my business manager manages.
I have been digging through the documentation for past couple days and read many stack overflow questions to no result.
No matter what I try, I simply get
{
"data" : []
}
These are some things I have tried:
<facebook_url>/v2.10/act_<accountID>/insights?fields=account_id
<facebook_url>/v2.10/act_<accountID>/insights?fields=impressions&date_preset=lifetime
They all respond with empty response.
Strangely enough, <facebook_url>/v2.10/act_<accountID>?fields=name gives me exactly what I want:
{
"name": <account_name>,
"id" : <account_id>
}
What am i doing wrong?

If you have not run any ads and have 0 ad spend, insights endpoint will not return those nodes. Only nodes which have data in the given time range are sent via the insights endpoint.

Related

How To Get All Active Campaigns, Adsets, and Ads Starting Today Facebook Marketing/Graph API

I am trying to query Facebook for all campaign, asset, and ad id's with their name and current spend, and whose start date is today. My current GET request inside of Graph API looks like this:
act_xxxxxxx/ads?fields=name,campaign_id,adset_id,insights{spend}&filtering=[{'field':'adset.start_time','operator':'GREATER_THAN','value':'1667448000'},{'field':'adset.start_time','operator':'LESS_THAN','value':'1667534400'}]&limit=1000&date_preset=today
Which which facebook returns
{"data": [ { "name": "Ad Name","campaign_id": "xxxxxx", "adset_id": "xxxxxxx", "id": "xxxxxxx"}...
I can confirm that the number of ads returned is equal to the number of active ads I have starting in that account today.
However, if you notice, there are no insights included, despite the fact all campaigns have spent hundreds today already.
In Graph API Explorer, I see this:
As you can see insights are greyed out, meaning the field is empty or disallowed.
I'm positive I have the proper permission on the ad account because when I remove the filtering within the query it returns spend values from prior campaigns (I can even set the start time minimum to yesterday rather than this morning at midnight and it will return yesterday's campaigns with spend).
So the issue here seems to be filtering, but I'm obviously not 100% sure, any and all help appreciated. Thanks!

How to get results from Facebook Insights API

I'm trying to get useful data from the Insights section using the the Graph API Explorer.
I've tried different metrics and dates, and the results for data is always empty.
I was able to look at my page dashboard for number of likes and select a range based on that, but I still don't see any data.
If the access_key is an issue, would it return an error saying so, or just return empty results?
Here is the debug output from a popular company that I would imagine has new likes in the past few weeks.
=== Query
curl -i -X GET \
"https://graph.facebook.com/v2.8/14226545351/insights/page_positive_feedback_by_type?since=1487788679&until=1490812690&access_token=<access token sanitized>"
=== Access Token Info
{
"perms": [
"user_likes",
"manage_pages",
"pages_show_list",
"public_profile"
],
"page_id": 167544343274096,
"user_id": "10152810337959467",
"app_id": 145634995501895
}
=== Parameters
- Query Parameters
{
"since": "1487788679",
"until": "1490812690"
}
- POST Parameters
{}
=== Response
{
"data": [],
"paging": {
"previous": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1484764668&until=1487788679&metric=page_positive_feedback_by_type",
"next": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1490812690&until=1493836701&metric=page_positive_feedback_by_type"
},
"__debug__": {}
}
=== Debug Information from Graph API Explorer
- https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=14226545351%2Finsights%2Fpage_positive_feedback_by_type%3Fsince%3D1487788679%26until%3D1490812690&version=v2.8
Is anyone able to give an actual working example? I have not come across any yet.
I discovered in the Graph API explorer, when you generate an access token, you need to give it permission "read_insights".
Also, this will only work on a page which your account has access to that given object.
Unfortunately the documentation is pretty vague in this area and there was no permissions error message give.
This might be a bit late, but better late then never I guess :)
On this Facebook docs page you can find a list of all the metrics you can use.
As for empty data, I had the same problem. I could never find how to get data from Facebook Insights; but thanks to the cheatsheet, I can give you an example:
Facebook Insights Example
https://graph.facebook.com/{page_id}?fields=insights.metric(page_fans)&access_token={access_token}
EDIT
Also, user Ravi Patel has a great, working example showing how to get insights from your posts:
/{page-id}/posts?fields=insights.metric(post_impressions_fan,post_engaged_users)
Original question

Facebook Graph API: unable to get shared posts although share count is higher than zero

I'm experiencing a weird behavior from the graph API: i want to list shares of a shared posts, so i'm requesting /<post_id>/sharedposts?fields=shares to get the number of times a shared posts has been subsequentially shared.
The response i'm getting, thus, is a list of objects like this:
{
"shares": {
"count": 1
},
"id": "136178893505927_155012298289253"
},
However, if i request /136178893505927_155012298289253/sharedposts, I get
{
"data": [
]
}
Which is weird, as I was expecting one object to be in the response.
Moreover, if I request /<post_id>/sharedposts?fields=shares,sharedposts i'm getting a weird list containing shares.count higher than 0 and no sharedposts content in some cases and a sharedposts array containing less elements than shares.count in some others.
I'm guessing this happens because the shared posts are not visible to my profile, but shouldn't I be able to see them, since the original post was published on a page I manage?
I'm trying to build the graph of shares to determine if a share being re-shared contributed more than others to the overall share count, but it looks like this is not feasible with the graph API...or am I missing something?
Use Graph api v2.3 and you need read_stream permission.
This permission is only in this version.

Get actual reach for several ads using Facebook Ads API

I'm looking for a way to get the overall reach for several ads on facebook (using facebook ads api). This reach should not be the sum of all ads reach, because if the same user saw 2 different ads, it should count him as 1 and not as 2.
It should not be a regular sum, but the number of unique users who were exposed to all or some of these ads.
Assuming you have a valid access token for the user that created those ads, you should be able to do something like the following:
HTTP GET https://graph.facebook.com/act_ACCOUNTID/reportstats?date_preset=yesterday&data_columns=['adgroup_id','reach']
Then in the response of the call, you should see something like
{ data: [ { adgroup_id: 1, reach: 100 } ] }
See https://developers.facebook.com/docs/reference/ads-api/adreportstats/ for the skinny on the ad report stats API.

getting insights about a page

I am trying to get the page insights.. the only metrics being shown are page_fans_country and page_storytellers_by_country. For rest of the metrics the following output is coming
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/22754734656/insights/page_fan_adds?since=1364712822&until=1364972022",
"next": "https://graph.facebook.com/22754734656/insights/page_fan_adds?since=1365231222&until=1365490422"
}
}
Even if there is no addition in the no of fans '0' value should come as the output.. I am stuck.. Please help
Thanks
I know that it won't answer the question correctly but...
Those insights are public so you just need an App, Page or User access token to request them.
However, Facebook is struggling to have its insights working properly. They use to be 3 days delay, now it's 5 days sometime. And now for few days it's not returning anything if you don't specify the date range. ie:
/cocacola/insights
is not returning anything but sometime it is (latest insights)
To fix it few weeks ago I've read that specifying the metric would do it, and yes:
/cocacola/insights/page_fans_country,page_storytellers_by_country
But now it's not anymore. The only thing working is if you specified since and until
ie: /cocacola/insights?since=1368503760&until=1368662399
But it's really a pain in the *** because you need to know which date is the latest available before to query your insights.
Facebook API sucks!