Facebook Insights API Conversions are NOT matching Facebook Ads manager Results - facebook

When trying to fetch Facebook insights API for the following action offsite_conversion.fb_pixel_purchase I always get less number than Facebook show on their ad manager, I tried to inspect their network calls and URL structure and I see they're using the same field offsite_conversion.fb_pixel_purchase to show Results I am not sure why the numbers are mis-matching. I tried to query from the Graph API and from my shell with the same results.

You may check use_account_attribution_setting and use_unified_attribution_setting in here: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/insights
Setting use_unified_attribution_setting to true worked for me.

I did some testing and found out that if you use an additional breakdown, FB will return less conversions. There might be a bug in their API when you use breakdowns.
I tried getting offsite_conversion.fb_pixel_purchase with
'breakdowns' => 'hourly_stats_aggregated_by_advertiser_time_zone',
and facebook retuned 5 conversions.
if I remove the breakdown and get the data grouped daily I get 11 conversions which is what Facebook Ads Manager shows

Related

Facebook Insights API not returning store visits data

I am trying to retrieve Store Visits data from the Facebook Insights API. Based on their documentation, these should be available by specifying the following parameters:
store_visit_actions
cost_per_store_visit_actions
When I use store_visit_actions as a parameter, no data is returned. I know data exists because it is displayed through their UI reporting tool.
When I use cost_per_store_visit_actions, I receive a 100 invalid param error:
cost_per_store_visit_actions is not valid for fields param.
These params are listed as "In Development", however, I'm retrieving other development parameters without issue. Is anyone facing the same issue or know how to fix?
this is because the metrics
store_visit_actions
cost_per_store_visit_actions
are deprecated in facebook api v11.0. You can checkout this link:
https://developers.facebook.com/docs/graph-api/changelog/version11.0/

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.

How to get Facebook page total likes number with the new Graph API (v2.4)

So recently there was a update to the Facebook Graph API and now pretty much everything requires a access_token to retrieve any type of data.
Previously you could get the number of page likes by accessing the graph like so:
http://graph.facebook.com/{page-name}
But now if you try it says you need to have a access token because of a recent update to the API. Now the issue i am having is i cant access the likes even with an access token this is the response i am getting:
Request
http://graph.facebook.com/{page-name}/?access_token={access_token}
Response
array(2) {
["name"] "Page Name"
["id"] "Page Id"
}
Now at first i thought the access token wasn't being generated with the correct scopes but i am 99% sure you only need read_stream to pull that type of data.
Second thought is that they have removed the ability to acces likes of any page and you need a page token to receive that type of data or finally i am missing something incredibly small here and its still achievable?
So my question is can you still get the number of likes of any page using the Facebook Graph API and if the answer is yes how do you do it?
any help appreciated
This can help you! Just add ?fields=likes after the page name/id. You can use any access token for fetching data!
graph.facebook.com/{page_name}?fields=likes&access_token={token}
The Graph API v2.4 reduces the number of fields in default responses.
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance: To help improve performance on mobile network connections, we've reduced the number of fields that the API returns by default. You should now use the ?fields=field1,field2 syntax to declare all the fields you want the API to return.
If you do ?fields=likes it should show up.
You can do like this:
https://graph.facebook.com/v2.4/{page_id}/fields=likes

How to get facebook share, like, comment count for a url with graph api only (in a non-deprecated way)

The problem is that after v2.1 of graph api fql will be deprecated.
Can someone tell me how to get separate likes, share count for given url using only graph api? I was looking for some documentation, but there isn't any, i can get only total "shares" which is likes + shares + comments.
Yes i know there is immortal http://api.facebook.com/restserver.php?method=links.getStats&urls, but what if facebook shuts it down at last?
The REST API (with calls like http://api.facebook.com/restserver.php?method=links.getStats&urls) was announced as deprecated with the introduction of the Graph API v2.1: https://developers.facebook.com/docs/apps/changelog#v2_1_deprecations but also already in 2011: https://developers.facebook.com/blog/post/616/
So, from my understanding, this will yield in the inoperability of this feature at two years after the introduction of v2.1 on 7th August 2016:
https://developers.facebook.com/docs/apps/versions#howlong
The closest you can get to the "old" REST of FQL API call results with the Graph API is this afaik:
https://developers.facebook.com/docs/graph-api/reference/v2.3/url/
but it omits the like_count metric (don't ask me why...).
My personal opinion is that you should continue to use the FQL calls to the link_stat (https://developers.facebook.com/docs/reference/fql/link_stat/) table, because this will be available for nearly the next 2 years. This is only possible if you have a v2.0 app. Maybe there'll be some additional endpoints for the Graph API until then.
I suggest using a tool like SharedCount, it offers a lot more platforms too. Here is how they get the data: http://www.sharedcount.com/documentation.php (Scroll down to "Sources")
So for Facebook it would be like this:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
You get a JSON object like this one:
..."share_count":66,"like_count":15,"comment_count":1,"total_count":82...
Edit: This is deprecated now, but there is another possibility, explained in this thread: Get FB likes, shares and comments for a URL using PHP - with no limit
You can use facebook graph api like https://graph.facebook.com/?ids=http://mycodingtricks.com and it will return a json code like
{
"http://mycodingtricks.com":{
"id":"http://mycodingtricks.com",
"shares":1
}
}
I have developed my own php script on which you can all social count using that api.
http://mycodingtricks.com/share/social.php?url=YOUR-URL-HERE and it will return data like:
{
"facebook":[
{
"share_count":1,
"like_count":0,
"comment_count":0,
"total_count":1,
"click_count":0,
"comments_fbid":567687199998199,
"commentsbox_count":0
}
],
"googleplus":10,
"twitter":3,
"buffer":0,
"pinterest":0,
"stumblupon":1,
"reddit":"<html><body><h1>403 Forbidden<\/h1>\nRequest forbidden by administrative rules.\n<\/body><\/html>\n",
"linkedin":0
}
But if you wants to use on your own Here is a complete article about how to count facebook share,like and all.
http://mycodingtricks.com/php/2-ways-to-count-facebook-likes-shares-and-comments-using-php/
actually the correct way for getting the like number is this:
http://graph.facebook.com/v2.5/?id=YOUR_URL&fields=og_object{engagement}
the brackets after the og_object is the second level of og_object.
see documentation here:
https://developers.facebook.com/docs/graph-api/reference/url
you might need to encode the url and brackets so it will look something like:
https://graph.facebook.com/v2.5/?id=ENCODED_URL&fields=og_object%7Bengagement%7D&id=http%3A%2F%2Fwww.cnn.com
see a working example in
graph explorer (hit the submit button)
All answers are wrong or incomplete since latest shut down of API 2.1!
I am the author of the social media plugin MashShare and i recently had to do exact observations for this issue as it seriously affected the share count of our plugin.
Verified data by observations:
https://graph.facebook.com/v2.7/?id=https://www.mashshare.net contains shares and likes.
As far as i found out the only way to get a number near the real share count of a post is to get first the likes of a url. Than take this number and subtract it from the total number of shares and likes.
To get the like count you need to take the object id of the url and create another API request:
https://graph.facebook.com/v2.7/14206851986099/likes?summary=true
If you know how to merge both requests into one please let me know.
As of August 19th 2016 facebook completely shutdown their rest API.
The only alternative is to use the graph API as suggested above.

/act_{account-id}/adcreatives creative_ids parameter is not working in the Facebook Ads Graph API

I have an application that uses the Facebook Ads OLD REST API and recently I heard that it will be deprecated in a month, so I'm working hard to migrate all my code to the new Graph API...
Unfortunately, nothing goes smoothly.
when calling to GET /act_{account-id}/adcreatives to get the AdCreatives for a specific campaign the parameter creative_ids is not working and always retrieving all the creative for the account!
This was working fine in the rest api... and no documentation changes were made in ads.getCreatives so I'm assuming creative_ids paramter is still there...
Any help will be appreciated!
thanks,
Yaniv Hakim
I found the _ids parameters to be finicky so I use the generic ids=comma-separated list parameter, without the act_{account-id}. Creative IDS are unique across accounts so there's no need to specify the account-id. If you want to use the specific parameters, have you tried creative_id, creativeids, creativeid and other permutations you can think of (with and without account-id)?