Get reports with campaign statistics by code - facebook-graph-api

The problem is I don’t have an access to ads api so I can’t get information about campaigns like impressions or click through rate.
However, I can make reports in ads manager. I am fine with amount of data in these reports. The question is how can I automate process of getting reports in my application?
Is there any other way how I can get campaign information such as in reports with no ads api access?

Unfortunately there is no way to do this without Ads API access.

Related

Instagram Post Insights - Organic v/s Paid Breakdown

According to Instagram (GRAPH) documentation, it's straight forward to get the insights of a post or media object (even story).
Unlike the Facebook insights of a post, Instagram (GRAPH) does not provide paid/organic breakdown on a post level for available metrics like impressions and engagement.
This creates a big issue for marketing teams because they cannot differentiate organic from paid performance.
Another way to try to hack this is by fetching all related Ads created on this post. I didn't find anyway to read Ads, AdSets or Campaigns related to a post ID. The only way I can think about this is to manually select the Ads related, on a condition that those Ads were created by the same Ad Account we have access to.
So my question is: Is it possible to get organic vs paid breakdown on the performance metrics of an Instagram post through the API?
from Facebook Developer support I know that the Instagram Graph API only reports organic results (so if a IG post received 300 likes, 200 of which from paid activities, an API call for the media insights will only return a value of 100 likes).
At the same time as far as I know the Facebook Ads API only returns the paid performance, not the organic ones.
For this reason you should be able to report the two sources separatedly, since the metrics don't overlap. The problem arises if you need to join the two sources (for example getting the like total of a single post), since as far as I know there's no matching variable between the media from Graph API and the Ads from Facebook Ads

Problems when trying to get Instagram stories through the Graph API

Problems when trying to get Instagram stories through the Graph API
Getting Insights Data
To get insights data for an individual media object, send a GET request to the /media/insights edge and include the metric parameter with one or more of the metric values you want returned. Please note the following limitations:
Insights data is not available for media objects within album carousels (children).
Stories insights are only available for 24 hours, even if the stories are archived or highlighted. If you want to get the latest insights for a story before it expires, set up a Webhook for the Instagram topic and subscribe to the story_insights field.
For the insights data Things i tried
https://developers.facebook.com/docs/instagram-api/webhooks
Subscribed the App with the POST call from Graph Explorer api
31231XXXXX/subscribed_apps
How do I Subscribe to the story_insights field of the media object??
Story Metrics
exits
impressions
reach
replies
taps_forward
taps_back

Facebook opengraph insights api on specific post id from my app

I want to build a dashboard that returns more customized insights from the insights generated by app.
The app is a facebook connect website that users visit and view a list of products. They can post to facebook about that particular product by sharing a custom story that incorporates that product on their timeline.
When I go to the insights for my app, it does a great job of showing me all social impressions for all custom stories that were generated on my site.
I'd like to narrow that down even more for specific products.
My plan is to record the object ids that are generated by these actions and link them to a partucular product in my database.
I'd then like to create a new dashboard page that will allow me to login, request read_insights permission from me and then use that object_id:product mapping from my database to show how many social impressions where recorded for a given product's object_ids.
Is this possible? I've read alot about it but still haven't found the most elegant way to get a segmented report of social impressions per type of content that was posted.
Thanks for your time.
The implementation all depends on which platform you want your app to run on.
The first major component is you must have a Facebook developers account which is easy to signup for. Just go to developers.facebook.com and register. Takes like 2 mins. After that you will need to create your first app and add the correct domain name where your app will be hosted and what platform it will run on. (iOS, Android, Web, ect.) Once that is finished you can make your app public so you can use the Facebook API in your code.
For the app creation itself. The first thing you need to do is import the correct API for your platform. Which you can find a walk through at https://developers.facebook.com/docs/. Once the API is imported you must build a Facebook object which contains your app id and possibly app secret. If you're using JavaScript you don't want to use the app secret because it will be visible to the public.
Now that you have your Facebook object you must require the app users to log in and grant permission to your app. You can add extended permissions to your log in process by adding a scope value to the log in button generated by Facebook. Here is an example.
<fb:login-button id="loginBtn" max_rows="1" scope="basic_info,read_insights,manage_pages" size="medium" show_faces="false" auto_logout_link="true"></fb:login-button>
After the user is logged in you can now query information from the users account using Facebook Api calls to Social Graph. Facebook also provides a tool to help you figure out what information you can query. https://developers.facebook.com/tools/explorer
Everything else you want to do with the app can be done by Facebook API calls. You just need to insure you grant the user the correct permissions before making the API calls.
API calls are a little different depending on which language syntax you are using but they all follow the same data model and return some array of responses which can be parsed using JSON or the standard array format. The Graph Explorer tool listed above will show you the output for your queries so you can handle them accordingly.
I hope this helps gets you started.
EDITED
Here's the implementation in JavaScript
function getMetric(){
// make the API call
FB.api(
"/{app-id}/insights/application_opengraph_story_impressions",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
}
Here's the reference now that Facebook docs are back up https://developers.facebook.com/docs/graph-api/reference/insights
application_opengraph_story_impressions will probably give you the total impression of all stories made by your app. I ran it against my Facebook app and it came back empty but I don't have any stories so it might work with your's. Also to note in the documentation there is an * by this metric and I could't find what that means.
I'm pretty sure that right now Facebook don't give developers ability to get insights about app custom stories.
Currently Facebook documentation has the following Graph APIs for Insights data:
/{page-id}/insights
/{app-id}/insights
/{domain-id}/insights
/{post-id}/insights (where this is a Page post)
So /{post-id}/insights won't work because custom story is actually user's post and others endpoints don't apply to your case.
As far as I know the only other option to access Insights is FQL. For that you'd use insights table in a manner similar to this:
SELECT ... FROM insights WHERE object_id = ... AND metric = ... AND end_time = ... AND period = ...
Now most likely this also won't work with your custom story posts (I don't have posts which I could try it on right now, so I can't tell) but at least it is not explicitly stated so in the documentation, so you should probably try it out.
UPDATE:
I wasn't able to get any insights data via FQL, although as far as I understand the following code should have gave me at least something (object id is for my page):
SELECT breakdown, end_time, event, metric, object_id, period, value FROM insights WHERE object_id = 224981264214413 and metric = 'page_fans' and period = period('lifetime') and end_time = 1395597892
But it results just in
{
"data": []
}
Facebook also has some pretty old bug report about similar topic: https://developers.facebook.com/x/bugs/508088155954330/ where they confirmed the issue, assigned it, and... did nothing to fix it for 6 months.
In case FQL doesn't work, my suggestion to you is - use your own analytics code to track the creation of custom stories and get the friend count of the users. It won't show you the real exposure of the posts but at least you will see some data on which types of custom stories where posted more often and what was the maximum potential friend count that could have seen them. By the way - to make charting easier, you could use Google Analytics events for that.

Is it possible to get insight metrics using Facebook API

I am interested in fetching all data available on this page (https://developers.facebook.com/docs/opengraph/insights/) with Facebook API. Is it possible to get raw data to use with my own graphing tools?
Yes. You can query the insights table using either the Graph API or FQL.
The insights documentation is not very clear, and in FQL especially, you need to manually ask for data points one period at a time. The FQL documentation is worth reading even if you're using the API since it defines all the different metrics which are available.
Visit the Graph API Explorer, get an access token with the Extended Permission read_insights and type /PAGE_ID_OR_USERNAME/insights into the search box. You'll see a bit of what is available.
You can drill down by adding parameters to the end of the url. For instance /PAGE_ID_OR_USERNAME/insights/page_fan_adds_unique/day?since=-1 month gets you a json object with the unique page fan adds each day for about the past month.
You are only able to get insights data for a page where you have admin rights.

Getting profile pictures via graph api results in "application request limit reached"

We receive "(#4) Application request limit reached" error when a page is showing the profile picture of a large amount of users.
Does it happens just because of referring the user's profile picture via graph api? e.g. "https://graph.facebook.com/{user-id}/picture"
If we will use the direct picture link (e.g. "http://profile.ak.fbcdn.net/...") and update it using the real-time updates the problem will be solved?
Thanks
If you are doing too many server calls to facebook app at once, you have a fair chance to get the error. Please check if getting the direct link is permitted in the facebook terms and conditions for platforms. Or else you can store the picture when someone connects through facebook in your server, but again, facebook changed privacy policy recently, so please check with that too.