Facebook Ads Insights API Not returning data for one ad - facebook

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?

Related

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

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.

Fetching comments from active facebook ads

I am working on a Facebook comment manager and I just can't manage to get only active ad creatives from Facebook API.
Is there a way to get all ad creatives filtered by their status?
I can't afford to check all ads manually, because I plan to pull ads every few minutes and I would be hitting Facebook's rate limit.
There are a number of endpoints that could help you do this, but would require you to make multiple API calls.
Step One: Get all Ads
Assuming you have managed to get the Ad Account ID from a previous API call, you will be able to get all Ads running against that account by making a GET request to the /act_{ad_account_id}/ads?fields=name endpoint.
Step Two: Get Images with Active Status
Next you can call the /{ad_id}/adcreatives?fields=name,image_hash,status endpoint for each Ad, which will return the name of the creative, the image hash that was used, and the status of the creative.
If you require the status of the actual Ad itself rather than the status of the creative, you will need to do another step in between Step One and Step Two, where you call /{ad_id}?fields=name,status on each Ad, then filter ACTIVE campaigns.
EDIT:
You can use /act_{ad_account_id}/adcreatives?fields=status,image_hash,title to get all creatives and statuses associated with the account. This would reduce your API call rate although would mean you would need to sort the creative to match with the ads. Using the title field would give the title of the ad it was used in the ad. Facebook does not offer any other fields related to the ad itself.
You can limit results to ads whose effective_status is ACTIVE.
Here is a sample request:
act_123/ads?filtering=[{"field":"effective_status","operator":"IN","value":["PAUSED"]}]
Ad fields
Insight Parameter

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.

Ads api: request only those creatives that are currently used

When using Facebook's Ads API, I'd like to request all creatives for an account that are currently being used by an adgroup. I.e. where the count_current_adgroups value is > 0. I can pull all creatives for the account with:
">https://graph.facebook.com/adcreatives/?ids=act_123456789&access_token=
How do you limit this request to only return adcreatives that are being used by an adgroup?
Thanks.
John - This functionality doesn't currently exist. Your best bet is to load all the active adgroups in your account like this:
https://graph.facebook.com/adaccount/adgroups
Inside of each adgroup, it will list the adcreative that is currently associated with that adgroup. Collect all of these adcreative IDs together, and deduplicate them, then load them all using this syntax:
https://graph.facebook.com/adaccount/adcreatives?ids=1,2,3,4
This should give you the functionality you need, although it will take two calls to the Facebook Ads API to compute what you want.

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!