Facebook Developer APIs - Trying to fetch all the campaigns, Adsets and Ads - facebook

This is what I'm trying to do -
The first GET request is to https://graph.facebook.com//<ACT_ID>/campaigns, which successfully returns me all the campaigns (Ofcourse I've handled pagination using the cursors provided)
The next step I perform is, for every campaign ID, I make a GET request to https://graph.facebook.com//<CAMPAIGN_ID>/adsets to fetch the respective adsets.
Here is where things go wrong. I get back an error which says limit (#17) User request limit reached after a few requests.
I have also tried using batch requests. But it appears as if the batch requests are in turn making individual multiple calls internally, which is again ending up in the request limit error.
Can anyone help me figure out how I can achieve this ? Bypass the limit or perhaps a different approach.
Thanks.
Please let me know if you need clarification on my question.
[UPDATE] : I have tried looking at the metrics from the header of an GET insights call. The CPU usage/call count/total time are way below the limits specified in the documentations. I have no idea why the request limit error is showing up.

I have found a way to fetch campaigns, adsets and ads in a single call.
https://graph.facebook.com/<ACT_ID>/campaigns?fields=id,name,adsets{id,name},ads{adset_id,name}
This will return an array of campaigns, with each campaign having arrays of adsets and ads that belong to it.
Now that I got the data, I can easily parse it according to the format I want which is each element in the array of campaigns having a array of adsets that belong to it. Each element in this array of adsets having an array of ads that belong to it.

Related

Facebook Ads Insights API Not returning data for one ad

I'm trying to pull some data from Facebook Ads Insights API and I get the correct data from one campaign/ad and with a different campaign/ad I get nothing.
It's "" vs. "{\"data\":[]}" (one is nothing at at, one is empty result)
The ad that returns data has a status of "Not Delivering" and the one that doesn't return anything has a status of "inactive". I only have two ads to work with currently. Can I not get data from inactive ads through the API? In the web interface the data is there. Is there a switch or something for inactive ads that I might not have or I might be sending incorrectly?
EDIT:
Actually, if I switch the order of which ad I pull first it changes which one returns nothing. Does Facebook Marketing API not like you pulling ad data one after the other? What is going on here?

Facebook API Campaign Create

Some background...
I'm trying to create a Campaign using the graph.facebook.com API. When I post, I get an ID back, which I thought would most likely be the Campaign-id, when I do a Get, I am returned a list of ID's...presumably campaigns.
When I go the AdManager page to see all my campaigns there is nothing. I have tried searching Adverts and Adsets, but also nothing. I now have a list of Id's but no idea what they actually represent.
If I do a GET on one of Ids I was hoping I might get some further information about the object (node), but instead I just get the id back and nothing else.
The AdAccount I am POSTing the campaigns to is a SandBox account, not sure if this makes a difference.
...
Can anyone confirm whether or not the id I am receiving is likely to be the CampaignId?
Is there a special way to see campaign's created for a sandbox account?
Is there a further stage I need to complete to get the Camapigns to show up?
many thanks.

Loading & Connecting Facebook Pixel Conversions Data

I am trying to load the Facebook Pixel Conversions level data from the Marketing/Insights API but not able to do it at the level I want or even properly
I have various pixels created in the form of events eg: Leads, Registrations etc and need to track them
After reading the documentation for Ads Pixels and it's stats - I was able to load some basic fields for now - but still not able to pull the s
GET API Query : https://graph.facebook.com/v2.9/act_/adspixels?fields=name,id,creation_time,last_fired_time
This gives me all the correct Ads Pixel details but how do I pull all the stats for this in the form of Events, their occurrences etc - will I be using more query parameters in this URL or a new URL - tried multiple iterations but was not able to get anything to work for now.
Tried this API Query as per documentation -: https://graph.facebook.com/v2.9//stats - but does not work even with fields added etc
Another issue I had was I am not at all able to test my queries with Graph API explorer - it keeps telling me that "Timeout issue" or "some other errors" when I am trying to use the app etc there. Do I need to publish and approve the app before hitting FB Ads data via the API Explorer?
All your suggestions and feedback will be highly appreciated here
I was searching for some things related and encoutered your thread.. I will report my findings .. maybe you already know this, but here it goes.
As far as querying with Graph API explorer.. it doesn't seem to work with Marketing API. You need to create your own app, and enable market api, in order to get the necessary token.
I am following the instructions on the link you provided: stats
Second.. to get the stats I am using
graph.facebook.com/v2.11/{pixel-id}/stats?aggregation=pixel_fire
The aggregation is necessary to get results. I can get the "Page View" event listed that I am tracking on a website.
I was able to compare these results, with the ones showed to me on the events manager page of the pixel.
Hope this helps

Maximum number of results for realtime API

We have a user who is getting 1000 results back from a realtime API query but is expecting more.
From the docs:
https://developers.google.com/analytics/devguides/reporting/realtime/v3/reference/data/realtime#resource
It does not appear that the realtime API response contains a facility for paging.
Is it correct to assume this API endpoint:
https://developers.google.com/analytics/devguides/reporting/realtime/v3/reference/data/realtime/get
Can return a maximum of 1000 results?
You need to remember that real-time is still beta. The real-time request doesn't include a next link which means there is no way to get extra data back.
Try setting &max-results=10000 see what that returns. The max rows for the Reporting API is 10000, however I have been unable to find any information on what the max number you can set in the Real-time API is. Real-time isn't returning an error if I set it to 10000 however I don't have an account with that many real-time users so I cant test it. I am going to send Google an email to see if I can get a verification what the max number is for the real-time api.
https://www.googleapis.com/analytics/v3/data/realtime?ids=ga:78110423&metrics=rt:activeUsers&access_token={accessToken}&max-results=10000
You might want to add a issue request to issues - google analytics requesting that they add nextlink at the very least.

Using GA Data Export API to Get All UA's

I am using the GA Data Export API to interact with Google Analytics and I'm making a lot of progress, I am using this URL Endpoint initially to pull all the profiles under an account:
https://www.google.com/analytics/feeds/accounts/default
This URL retrieves each GA ID (profile) and each UA. One thing I've realized is one account can contain multiple UAs and when this happens, this request pulls all profiles. We have a client who has about 115 profiles under like 10 different UAs, and the request takes about 30 seconds for the initial request (and then I believe it must be cached, because it speeds up considerably after this, but then the next day the same thing occurs).
Is there a way to get a list of UA's without pulling the profiles? This way I can query the UA specifically for the profiles instead of pulling each one.
Any advice on this would be really helpful!
Thanks
UPDATE: Here's some documentation on the specific call I am using right now:
http://code.google.com/apis/analytics/docs/gdata/gdataReferenceAccountFeed.html
UPDATE 1: I have found some interesting information in the docs
Once your application has verified
that the user has Analytics access,
its next step is to find out which
Analytics accounts the user has access
to. Remember, users can have access to
many different accounts, and within
them, many different profiles. For
this reason, your application cannot
access any report information without
first requesting the list of accounts
available to the user. The resulting
accounts feed returns that list, but
most importantly, the list also
contains the account profiles that the
user can view.
So this means that you have to use the default accounts call to get these back? Surely, somebody has had this issue before?
So apparently, you can query the account if you know the UA-ID, however there is no way to get back a list of only UA IDs.
One way you can do it is have the user enter their own UA ID instead of having them choose one; not as user-friendly as it could be but better than making the user wait 30 seconds!