I am extracting Ad Insights. I am using Facebook Marketing API.
I want to extract Spend & Offsite Conversions.
So following are the details:
fields: account_id, account_name, campaign_id, campaign_name, adset_id, adset_name, spend, actions
Breakdowns: hourly_stats_aggregated_by_audience_time_zone
actions_breakdown: action_type
Does anyone knows how facebook returns data? I mean how the data is returned by audience time zone at hourly basis by using above breakdown. You can refer to following sample response.
{
"data": [
{
"impressions": "1148",
"date_start": "2016-03-05",
"date_stop": "2016-04-01",
"hourly_stats_aggregated_by_audience_time_zone": "00:00:00 - 00:59:59"
},
{
"impressions": "172",
"date_start": "2016-03-05",
"date_stop": "2016-04-01",
"hourly_stats_aggregated_by_audience_time_zone": "01:00:00 - 01:59:59"
}],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MjMZD"
}
}
}
If my ad is targeted in multiple regions(diff timezones) then how the data will be returned?
I don't have any timezone information to know which local timezone this data is aggregated.
Any help would be appreciated. Let me know my assumption about any term related to Facebook Marketing is incorrect.
The response format, as CBroe pointed out, is https://developers.facebook.com/docs/marketing-api/insights/breakdowns/v2.9#hourlybreakdowns
The data aggregation is based on audience's local time. If people are in different timezones, they all use their own local time for aggregation. (i.e. This can used to learn whether your ads are more effective during morning time or evening time.)
Related
I'm trying to search and retrieve news articles on Alchemy Data News. I can get results using entities:
https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.entities.entity=|text=Neil%20Tyson,type=Person|
and I can get results using keywords:
https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.enrichedTitle.keywords.keyword.text=solar%20System
but if I combine the two I just get results that say "OK":
https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.enrichedTitle.keywords.keyword.text=solar%20System&q.enriched.url.entities.entity=|text=Neil%20Tyson,type=Person|
{
"status": "OK",
"usage": "By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html",
"totalTransactions": "4320",
"result": {
"status": "OK"
}
with no docs. Is this supposed to work, or am I barking up the wrong tree?
The problem is you've created a query with 0 results. If you remove the &return portion of the query the response will include only a count. You can also add &timeSlice to see results by time bucket (more on counts and time slice here). Running your combined query with a monthly time slice (&timeSlice=1M) returns:
"status": "OK",
"totalTransactions": "4322",
"result": {
"count": 0,
"slices": [
0,
0
],
"status": "OK"
}
An example of the combining entity and and concept with many recent/topical response (at least during Feb 2016) is replaceing Solar System with B.o.B:
https://access.alchemyapi.com/calls/data/GetNews?outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title&enriched.url.url&enriched.url.entities&enriched.url.concepts&q.enriched.url.entities.entity.text=Neil+Tyson&type=Person&q.enriched.url.enrichedTitle.keywords.keyword.text=B.o.B&apikey=<YOUR API KEY>
and that's where the focus of this service is, querying and helping identify trends in recent news.
I'm using facebook graph API in my Unity Application. What I'm trying to do is to retrieve the users using my application and show the first 20 ones ordered by score.
In the example project "friend smash" there's the following graph API call:
FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
This, as far as I know, gets 20 users who are using my application. Due to the poor graph API documentation I can't understand if user.limit(20) just returns 20 random users, or ordered with some criteria.
If this call returns random users, do I have to send one query for each friend, sort them by score and show only the first 20 ones to get a proper ranking? (I guess it would be quite query heavy though)
In Facebook Graph Explorer use following GET request to receive friends with score (descending order):
app/scores?fields=score&limit=20
It should return following Json:
{
"data":
[
{
"score": 1,
"user":
{
"name": "1st Name",
"id": "first_id"
}
},
{
"score": 0,
"user":
{
"name": "2nd Name",
"id": "2nd_id"
}
}
]
}
https://developers.facebook.com/docs/games/scores/#read-many-scores:
You can read the set of scores for a player and their friends by issuing an HTTP GET request to /APP_ID/scores with the user access_token for that app. The user_friends permission is required in order to view friends' scores. This returns a list of scores for a player and friends who have authorized the app. The list is sorted by descending score value, so it returns friends with the highest scores first.
(Highlighting by me.)
How can I get list of facebook likes (pages that user has liked ) with descriptions
Im using /me/likes object, but it won't give me likes descriptions. I understand I can use FQL with "WHERE page_id in (LIST_OF_IDS)" - or request for every like separately
Is there any way to get it with one request ?
Yes, this can be done via FQL with the following query:
SELECT name, description FROM page WHERE page_id IN (SELECT page_id
FROM page_fan WHERE uid=me())
https://developers.facebook.com/tools/explorer?fql=SELECT%20name%2C%20description%20FROM%20page%20WHERE%20page_id%20IN%20(SELECT%20page_id%20FROM%20page_fan%20WHERE%20uid%3Dme())%0A
Or this way using the Graph API: USER_ID?fields=likes.fields(description)
If it is possible with the Graph API, don´t take FQL. The Graph API is usually faster and easier:
me/likes?fields=id,name,description
Result (from my account):
"data": [
{
"id": "244993732224805",
"name": "Jón Gnarr",
"created_time": "2012-12-06T00:35:43+0000"
},
{
"id": "161086703983",
"name": "Design Shack",
"description": "We only offer the cream of great design, filtering through lots of the redesigns that occur every day across the Internet, and cataloguing the greatest projects out there - perfect for getting that spark of creativity going again.\n\t\nRegular articles will teach you new techniques for creating your own designs, and daily community news ensures that you're up to date with the latest developments elsewhere.\n\t\nIf you want to be updated every time a new design or tutorial is added, you can subscribe:\n\t\nDesign Shack RSS Feed\nhttp://feeds.feedburner.com/designshack\n\nTwitter\nhttp://twitter.com/designshack",
"created_time": "2012-12-04T14:40:08+0000"
},
{
"id": "274797542535942",
"name": "Chasing Aurora",
"description": "Chasing Aurora is an explorative 2D aerial action game about the dream of flight.\n\nDrop from the cliff and ride the wind from peak to peak. Fight for the beacon of light with up to three friends in the hostile environment of the Alps.",
"created_time": "2012-12-04T12:07:13+0000"
},
...
I m trying to retrieve the page_fans using the following FQL query (Insights Table).
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_fans' AND end_time=1334905200 AND period=86400
But I just get blank data , when I make the above query.
{
"data": [
]
}
I m able to retrieve the other metrics by just changing the metric value in the above query.
For Eg. I get the page_engaged_users by just changing the metric value in the above query.
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_engaged_users' AND end_time=1334905200 AND period=86400
{
"data": [
{
"metric": "page_engaged_users",
"value": 35
}
]
}
What is wrong with the first query in which I m trying to retrieve the page_fans ??
And I know that I can retrieve page_fans using other ways as well !!
If you look at the insights documentation, notice in the last column that the page_fans metric is only available for the lifetime period. Change your query to period=0 or `period=period('lifetime') and you'll get data.
If you want the new fans added on a given day, use the page_fan_adds metric with period('day').
If you request any other period, you will either get an error or no data (which means someone other than you can request that metric for a different period).
The other problem could be that you are requesting data that is too recent. In your query, you're looking at 2012-04-20, so you should be fine. When I tested this, I got no data if I used a date greater than 2012-09-15 (on 2012-09-18).
I'm trying to get some statistical data from my page using FQL like so:
SELECT metric, value FROM insights WHERE object_id=278942378807967 AND metric='page_fan_adds' AND end_time=1327903200 AND period = 2592000
However all that is returned is:
{
"data": [
]
}
I also tried different dates and periods, most of which I'm pretty sure there should be data presented...
You're probably missing a valid access token on your query to get the stats.
period can only be 86400 or period("day")