How to extract Campaign level conversions from Facebook marketing API? - facebook

In Facebook ad manager, I can see different categories of conversions against each campaign i.e.
Website Purchases 9
Website Adds to Cart 724
Website Registrations Completed 6
Website Checkouts Initiated 24
Website Searches 272
I am using graph API to extract this data from Facebook Marketing API(insights, attribution)
Firstly I tried to extract campaign level conversions from insights using
act_ad_Account_ID/insights?date_preset=this_month&action_attribution_windows=7d_click&level=campaign&fields=campaign_name,conversions,conversion_values,cost_per_conversion
But I could not see the categories i.e. website purchases, adds to cart etc. in the retrieved data.
Then I tried using attribution
with query
<Business Unit ID>/conversion_events?fields=name,id,cost_per_1k_impressions
as a result, I retrieved these categories associated with business unit ID overall.
"data": [
{
"name": "Website Searches",
"id": "11*******772",
"cost_per_1k_impressions": 11388.238
},
{
"name": "Website Adds to Cart",
"id": "1121******775",
"cost_per_1k_impressions": 188.238
},
{
"name": "Website Purchases",
"id": "11***********7874",
"cost_per_1k_impressions": 7088.238
},
{
"name": "Website Checkouts Initiated",
"id": "11212**********",
"cost_per_1k_impressions": 17088.238
},
{
"name": "Website Subscriptions",
"id": "1********80141",
"cost_per_1k_impressions": 1137088.238
}
But these are overall stats, I want to retrieve these stats at campaign level. Where to put down a campaign filter. Just using these API first time.

answering my own Question here.
We can get conversion data from insights here:
act_ad_Account_ID/insights?date_preset=this_month&level=campaign&fields=campaign_name,actions
actions return a json, that contain
Website Purchases 9
Website Adds to Cart 724
Website Registrations Completed 6
Website Checkouts Initiated 24
Website Searches 272
all these conversions data that we can see on facebook ad manager against each campaign.

Related

How to get facebook account billing information through facebook graph

I'm trying to get the Current balance and Payment threshold of an ad account using FB Graph API.
But I didn't find these two fields in the graph-api documentation. https://developers.facebook.com/docs/graph-api/reference/adaccount
Facebook Account Billing Screenshot
Here are some fields I get, but not what I need.
https://graph.facebook.com/v15.0/act_2544045166952?fields=currency,spend_cap,balance,amount_spent&access_token={access_token}
`
{
"currency": "USD",
"spend_cap": "0",
"balance": "0",
"amount_spent": "1900",
"id": "act_2544045166952",
"__fb_trace_id__": "Dk04/LHZUMS",
"__www_request_id__": "A0lv2zw3GMOoUUnZkuGmcHh"
}
`
Where can I find this information in the Graph API?

Facebook Graph API not returning posts likes

I am trying to retrieve the number of likes for posts in a Facebook page. For instance, I am calling the following endpoint from Graph API explorer
nba?fields=posts{message, likes}
to retrieve posts from NBA page. But I only managed to retrieve message and id but not the likes. Is it because of new privacy policy?
`
{
"posts": {
"data": [
{
"message": "๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜ฎ Does ANYBODY get better bench reactions than Klay Thompson??
๐Ÿ‘€: Golden State Warriors x Cleveland Cavaliers Game 3
๐Ÿ“บ: 9 pm/et Wednesday, #NBAonABC",
"id": "8245623462_10156593269718463"
},
{
"message": "๐Ÿ“ธ x #NBAFinals Game 2",
"id": "8245623462_10156593260853463"
},
{
"message": "Game 2 in #PhantomCam! ๐Ÿ‘€ the BEST of Stephen Curry, LeBron James, & more slowed all the way down.
NBAFinals presented by YouTube TV",
"id": "8245623462_10156592692223463"
},
{
"message": "George Hill added 15 PTS, 3 AST for the Cleveland Cavaliers in game 2 at Oracle Arena. #NBAFinals presented by YouTube TV",
"id": "8245623462_10156590505838463"
},
{
"message": "๐Ÿ—ฃ Stephen Curry somehow beat the shot clock with this WILD 3-pointer! Hear how it sounded around the world #GlobalGame ๐ŸŒŽ๐Ÿ€
`
https://developers.facebook.com/docs/graph-api/reference/v2.12/object/reactions
Likes are call "reactions" now ,(
thumb and , emoji reactions)
But I only managed to retrieve message and id but not the likes. Is it because of new privacy policy?
Yes. You will need admin access (page access token) now to get individual likes.
If you only want the number of likes though, you can ask for the summary field:
nba?fields=posts{message,likes.summary(1)}
And be aware, you will still need to get your app reviewed for Page Public Content Access, otherwise you wonโ€™t be able to get any info about pages you do not have admin access to. It works using above example link when using the Graph API Explorer app id - but as soon as you switch to one of your own, you will get an error saying you need PPCA, if the app in question isnโ€™t already approved for that.
Yes it is, more information than public available (by example the likes, now just called reactions) options will be closed soon.

How to get social media links from Google Knowledge

Currently I'm working on a project that require me to collect celebrities followers number (from instagram or facebook).
To get that number, i have to get
1. celebrities instagram link
2. celebrities facebook link
3. send a request to instagram or facebook API to get their followers number
I have been researching for google knowledge API for celebrities instagram and facebook link. but what I get from it isn't satisfying.
For example, I put a request on google Knowledge,
https://kgsearch.googleapis.com/v1/entities:search?query=Ariana+Grande&limit=1&indent=1&key={API-CODE}
and the result is
{"#context": {
"#vocab": "schema.org/",
"goog": "schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"resultScore": "goog:resultScore",
"kg": "g.co/kg"
},
"#type": "ItemList",
"itemListElement": [
{
"#type": "EntitySearchResult",
"result": {
"#id": "kg:/m/09gkdy4",
"name": "Ariana Grande",
"#type": [
"Thing",
"Person"
],
"description": "Singer",
"image": {
"contentUrl": "t0.gstatic.com/images?q=tbn:ANd9GcS3KH3ae6ChLCPLguyQXbLbEXDTNMZ1Sb2LsMx6Vr-pjeuHg5AZ",
"url": "da.wikipedia.org/wiki/Ariana_Grande",
"license": "creativecommons.org/licenses/by/2.0"
},
"detailedDescription": {
"articleBody": "Ariana Grande-Butera, known professionally as Ariana Grande, is an American singer and actress. She began her career in the Broadway musical 13, before landing the role of Cat Valentine on the Nickelodeon television series Victorious in 2009. ",
"url": "en.wikipedia.org/wiki/Ariana_Grande",
"license": "en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "www.arianagrande.com"
},
"resultScore": 802.862244
}
]
}
There's no information regarding her instagram or facebook link from the result, but if we search manually on google, it shows her instagram and facebook link on search result.
My question are:
1. Any way to get those link from Google knowledge?
2. Or any easier way to get follower number from celebrities beside my way? (jugling from 2-3 different APIs)
Thanks.
I really appreciate any comment and help.
You can use wikidata.org. There are steps:
Search https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Ariana+Grande&language=en&format=json
{"searchinfo":{"search":"Ariana Grande"},"search":[{"id":"Q151892","concepturi":"http://www.wikidata.org/entity/Q151892","url":"//www.wikidata.org/wiki/Q151892","title":"Q151892","pageid":153289,"label":"Ariana Grande","description":"American actress, singer, composer and dancer","match":{"type":"label","language":"en","text":"Ariana Grande"}}],"success":1}
Get id Q151892 from the response and get the entity https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q151892&format=json&props=claims
There is a big response. You need the value arianagrande of claim P2003 from a list of claims. It refers to Instagram username (P2013 for Facebook)
Get public info from https://www.instagram.com/arianagrande/?__a=1
user:
follows:
count
followed_by:
count
media:
count

Can I aggregate Facebook Likes, Tweets, and Google Pluses?

I'm building a voting application on my new website, cabinethardware.org. I'd like the voting to be done in such a way that when someone votes for a project (to receive a $1000 rebuilding grant) that they are encouraged to plug the project via social networks. My programmer has had difficulty with the application, and it occurred to me that one way of doing it is to just put like, tweet and G+ buttons on the site and add them together. So if a project gets 24 likes, 12 tweets, and 18 G+, it would have 64 votes. It doesn't bother me if someone votes on all three engines.
Before a project is eligible for a grant, it must receive 100 votes. My question is, is there a way that I can aggregate the likes, tweets, and G+ so that I can see on the backend how many votes each project has, without going to each project and adding them up by hand? Also, I'd like to display to customers the combined total.
Does anyone know of a way to combine the count of these three?
For Google+, you would only need to perform one API call to the Google+ APIs that would be searching the Google+ public data. Searching the Google+ public data is demonstrated in the API explorer.
The post response contains information about reshares and +1s:
"verb": "post",
"object": {
"objectType": "note",
"content": "Setting up a server-side flow project that accesses Google+ data using the .NET stack can be a little tricky, I walk you through it in this blog post.",
"url": "https://plus.google.com/109716647623830091721/posts/g8LjdGAXdDc",
"replies": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/comments"
},
"plusoners": {
"totalItems": 6,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/plusoners"
},
"resharers": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/resharers"
},
For Facebook, you can use the Pages API to count likes for your page, you can experiment with this in their API explorer.
The following data shows their response data:
{
"about": "Build and distribute amazing social apps on Facebook. https://developers.facebook.com/ ",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
"is_published": true,
"talking_about_count": 39241,
"username": "FacebookDevelopers",
"website": "http://developers.facebook.com",
"were_here_count": 0,
"category": "Product/service",
"id": "19292868552",
"name": "Facebook Developers",
"link": "https://www.facebook.com/FacebookDevelopers",
"likes": 952596,
"cover": {
"cover_id": "10151121467948553",
"source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/s720x720/299374_10151121467948553_45631061_n.png",
"offset_y": 0
}
}
Likes are just a member in the response data.
For twitter, you can query for mentions of a user with their search API and passing a search string for the user as #user. A count of the objects within results is going to be your mention count. The response data is a little too much to paste in here but here's an example query using their API.

Scope of Facebook API

I am trying to learn and create a Facebook API on the go. However, I haven't found any page on the developer pages that specifies the scope of the Facebook API in great detail. I understand public information can be accessed using Graph API. But at the same time understand that further access is possible, not sure how much though.
Is there anyway to access the 'Edit news feed options' of a user that authorizes an application?
I don't really understand what you mean by "scope", but the Graph API is not more than a series of URLs to contact the facebook servers with queries and obtain answers in form of JSON objects.
You can start learning by looking at the reference for the API here:
http://developers.facebook.com/docs/reference/api/
There are unofficial APIs for every language you can imagine, for example java: http://code.google.com/p/facebook-java-api/ , c#: http://facebooksdk.codeplex.com/ , etc.
To read the news feed, you can access it by:
https://graph.facebook.com/me/home?access_token=TOKEN (where TOKEN is the access token)
Fb will respond with a JSON object similar to the one pasted below.
{
"data": [
{
"id": "11111_1111111111,
"from": {
"name": "Name",
"id": "11111111"
},
"message": "SOME_MESSAGE",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/111111/posts/11111"
},
{
"name": "Like",
"link": "http://www.facebook.com/11111/posts/11111"
}
],
"type": "status",
"created_time": "2011-04-20T20:19:04+0000",
"updated_time": "2011-04-20T20:19:04+0000"
},
etc etc etc
],
"paging": {
"previous": "https://graph.facebook.com/me/home?access_token=TOKEN",
"next": "https://graph.facebook.com/me/home?access_token=TOKEN"
}
}
Having that, you can use the ID for the person or the message to perform new queries, as explained in the FB API page:
All of the objects in the Facebook
social graph are connected to each
other via relationships. Bret Taylor
is a fan of the Coca-Cola page, and
Bret Taylor and Arjun Banker are
friends. We call those relationships
connections in our API. You can
examine the connections between
objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE.
The connections supported for people
and pages include:
Almost every information on FB is accessible through the Graph API, provided the user authorized the app with the rigth permissions:
http://developers.facebook.com/docs/authentication/permissions/