Unable to pull most page insights metrics using Graph API - facebook

I am attempting to pull page insights metrics using the Facebook Graph API Explorer, but only a handful seem to be accessible. After failing to pull these metrics using the "read_insights" permission, I checked every box from "User Data Permissions", "Friends Data Permissions", and "Extended permissions." I still can not access most metrics.
An example GET request:
//insights/page_fans
...returns an empty dataset even though I am an administrator of this page and have permission to access to this data. I currently only get data back from: page_story_adds_unique, page_friends_of_fans, page_admin_num_posts, page_admin_num_posts_by_week.
Any insight would be appreciated.

See answer at https://stackoverflow.com/a/16894466/897489 - the default time span Facebook uses is not working because they appear to have missing data. You need to use since and until to get anything useful out.

Related

Facebook Graph API - User doesn't have enough permissions to load insights

I'm seeing this error for a page with this endpoint:
12345566/feed?fields=insights.metric(post_impressions_unique,post_impressions)
and I'm seeing this error: User doesn't have enough permissions to load insights
I've added the following permissions: read_insights pages_read_engagement, etc that is required according to the docs here but when I contact Facebook Developer support they say I have to add it at to Granular Scope.... how do I do this? I've attached a picture showing what the token debugger shoes for this Page Access Token permissions
I did have a similar issue on some of my pages. I did reach the Facebook's support on the matter.
TL;DR use /published_posts instead of /feed
Facebook's support full reply:
I have investigated this and I have a solution for you. Instead of using the /feed endpoint for the Page, please use the /published_posts endpoint instead.
The 'feed' for a page includes posts made by other Users/Pages when they tag your Page. When you try to access the insights for these posts made by other accounts, we run into the issue that this access token does not have the permissions to view those insights.
The 'published_posts' endpoint only includes posts made by the page itself, so you will be able to retrieve the insights using this.
Thank you for flagging this to us. I will see if there are improvements that could be made to our documentation or error messaging to improve the experience of other developers.

Azure Logic apps Facebook connector gives empty response

When I try to use the Facebook connector in Azure logic apps I can't seem to get the "Get user timeline" to work.
I know for a fact that the User ID is valid (I checked using this URL: https://www.facebook.com/profile.php?id=). I also know for sure that the user has posts on it's timeline. I also tried multiple user ID's.
When I open the failed request in the Logic app I get this, the response is empty every time.
Is this related to privacy settings? Why doesn't this work?
We should probably retire/remove that operation. It is not possible to retrieve the post from Facebook graph API for another user's timeline. It used to so that is why it is there. Specifically, this post might be helpful: Facebook Graph API {user-id}/feed from others empty
The connector calls the /{user-id}/feed API. You can try out the behavior in the Facebook Graph explorer as well. https://developers.facebook.com/tools/explorer/

How to request all insights for a page Facebook API

I am developing an application which will need to access multiple page insight metrics for a Facebook page. However, rather than running multiple queries for the metrics that I would like, I was wondering if I could just request all of a page's insights. I thought that to get that, I could just use:
{page-id}/insights
However this query returns a "FacebookAuthenticationException." When I run this query on the Graph API Explorer, I get the user message "No metric specified."
So is there anyway to retrieve all of a page's insights?
I thought that to get that, I could just use: {page-id}/insights
No, that is not possible any more.
https://developers.facebook.com/docs/apps/changelog#v2_7_changes:
Page Insights Change Page metrics insights must now be explicitly specified when making Page Insights related requests. The default behavior of returning all metrics when none are specified is no longer supported.
So you will have to pick the metrics you are interested in, and request those specifically:
{page-id}/insights/metric_name1,metric_name2,...

How can I programmatically retrieve Facebook Audience Network performance data by hour?

I'm spinning my wheels over here and could use some help.
For our internal app analytics system, I have a script that currently uses the FB App Insights Reporting API to get basic Fb Audience Network ad metric data (requests, impressions, revenue, etc.):
https://developers.facebook.com/docs/graph-api/reference/v2.6/application/app_insights
It only reports data by day though (even though it misleadingly returns a Timestamp with the response), and we now have a business need to collect this data by hour, so we can accurately generate reports for any time zone.
I came across another part of the Graph API that seems built for this specific reporting purpose, and, according to the documentation, does support hourly granularity:
https://developers.facebook.com/docs/graph-api/reference/v2.6/user/adnetworkanalytics
I am moderately familiar/comfortable with FB API security and design, but for the life of me I cannot get anything but an empty data list back from this API edge. Sample request:
https://graph.facebook.com/v2.6/<user_id>/adnetworkanalytics?since=1467176400&until=1467262800&event_name=fb_ad_network_request&aggregateBy=COUNT&breakdowns[0]=country&breakdowns[1]=placement&breakdowns[2]=app&period=hourly&access_token=<user_token>
From what I can tell this means that the 'User' (me, or technically the dummy app I have set up to access Insight API data through) does not have correct permissions to access this data, and indeed when I check my permissions I do not see the associated permission, read_audience_network_insights listed.
I have tried to add the permission to the app I am accessing this through by adding the permission through the Graph API Explorer in the dialog that pops up when you select 'Get User Access Token.' However, even after adding there I still do not have the associated permission granted, even though it shows in the dialog if I go through the process again:
I think this is because I have to submit this App to FB Review for that specific permission, but when I try that, I do not see the permission available to be selected for review.
SUMMARY:
Like my title says, my goal is just to get my FB Audience Network data by hour. I'm open to any programmatic way of doing this (preferably something I can implement in a python script). If that means someone helping me get permission and successfully use the adnetworkanalytics edge that is great. If it is through other means I am not aware of yet, that is great too. Thank you!

Open Graph insights for specific post

We have a Facebook Application with custom Open Graph objects and actions.
We then use a App Access Token to post stories for a particular user from our backend with the normal Open Graph REST API. After the post-call succeeds we log the returned "id" of that post.
Now we would like to collect insight data (e.g. post_impressions_unique) for some of these individual posts/stories using the logged id's.
According to https://developers.facebook.com/blog/post/573/ we should be able to do something like:
https://graph.facebook.com/[POST ID]/insights
Even though this call seems to work using our normal App Access Token, no insight data is returned for the post/story.
Does anyone know if this is possible and how to do it?
We have been experimenting with a normal User Access Token and the "read_insights" permissions, but with no luck. I have read some similar questions but mainly regarding page-posts (this is an App Open Graph post/story).
EDIT:
The facebook article above only refers to "Page" posts. I'm looking for analytics on individual Facebook App Opengraph Posts/stories. It seems difficult to find any good information about this, has nobody attempted this with any success?
You must add insights into a permissions/Extended permissions
Article :
Getting Page Insights
In order to obtain Page Insights via the Graph API, you must use a Page access token, and you must have the read_insights permission. Click on the link below to see this working in the Graph API Explorer.