getting insights about a page - facebook-insights

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!

Related

Facebook graph API does not return any metric from two days

I have been using graph API since june 2017 but from past two days its giving empty data for all metrics.
Does anyone know whats wrong with API??
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/v2.10/pageid/insights?access_token=pageToken&pretty=1&since=1506495600&metric=**page_fans**&until=1506582000",
finally the query got resolved and now the data is coming smoothly.
Don't know how the read_insights permissions got removed for the app associated with my page.
gave the read_insight permission again and the code is running very well now.

facebook marketing insights empty response

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.

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 API page_impressions/page_storytellers by age_gender return empty array

i am currently working with the Facebook API pulling data for an analytics platform, i have managed to retrieve everything Facebook has to provide but when it comes to
332405516848997/insights/page_impressions_by_age_gender_unique
332405516848997/insights/page_storytellers_by_age_gender
332405516848997/insights/page_storytellers_by_country
the following calls return :
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/332405516848997/insights/page_impressions_by_age_gender_unique?since=1374763564&until=1375022764",
"next": "https://graph.facebook.com/332405516848997/insights/page_impressions_by_age_gender_unique?since=1375281964&until=1375541164"
}
}
My access token has the required permissons (manage pages, read insights).
I am using the Facebook Graph API explorer.
Any help would be greatly appreaciated.
Thanks in advance.
After digging to the earth's core and back i stumbled upon the following :
Note: That start and end dates can be applied using since and until unix timestamps based on midnight in PST described in UTC.
Turns out it was the midnight pacific time range that was causing the issue.
Docs

Retrieve Facebook Insights older than 3 months with Graph API

I am using Facebook Graph API to retrive page insights information. My issue is that I can't get the ones older than 3 months. For example if I use /insights/page_fan_adds/day?since=2013-01-20&until=2013-04-23 is all working fine but if I use /insights/page_fan_adds/day?since=2013-01-19&until=2013-04-23 (one day before the previous since) I receive the following error:
{
"error": {
"message": "Unsupported operation",
"type": "FacebookApiException",
"code": 100
}
}
This means is not possible to get older information from the facebook page insights or I have to do something else like for example use some permissions or use other syntax?
Facebook will not allow more than 89 days, but you can adjust the since/until fields to get data older than 89 days.
Facebook will return up to 93 days of insights data. You can verify this for yourself by experimenting with the since and until fields.
If you need more than 93 days, as suggested in another answer, you'll have to modify the since and until fields to get different "windows" of data. Note that in the data returned by Facebook, paging URLs are included for your convenience. You can use them instead of reconstructing the URLs if you so desire.