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.
Related
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.
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
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?
I'm trying to create an ad for an unpublished page post (link type) via FB Ads API with goal set to WEBSITE_CONVERSIONS. I was a bit puzzled by api docs, so I checked hwo FB Ad Manager does this and notices it send "OBJECTIVE" parameter to FB - something that doesn't exist in API Docs at all
I have a php script in cURL that does the job, sending the following to act_xxxx/adgroups endpoint:
method=post
access_token=xxxxxxxxxxxxxxxxxxxxxxxxxx
name=CURL 001
campaign_id=xxxxxxxxxxxxxxx
targeting={"countries":["US"],"age_min":13,"broad_age":1,"page_types":["feed"]}
bid_type=ABSOLUTE_OCPM
bid_info={"ACTIONS":25}
adgroup_status=ACTIVE
creative={"type":27,"object_id":"XXXXXXXXXXXXXX","story_id":"XXXXXXXXXXX"}
objective=WEBSITE_CONVERSIONS
conversion_specs={"action.type":["offsite_conversion"],"offsite_pixel":["XXXXXXXXXXX"]}
redownload=1
When I go to FB Ad Manager and open the campaign, I can see the ad with correct objective set. Everything looks OK even if I open it with FB Ad Manager.
However, when I send the same request using the application I work on, things get messy. From FB Ad Manager campaign view, everything looks OK, but when I open the ad for editing, I get the following error for my Objective: You've entered a destination that can't be used with the Website Conversions objective. Edit Objective.
So, am I missing something, is there a point in API where this is explained?
Thank you and sorry for the long explanation.
EDIT: After inspecting the ad I created via FB Ads Manager, I noticed that creative it generated had (among other) title, image_url and link_url fields, even though creatives of type 27 shouldn't have those (according to https://developers.facebook.com/docs/reference/ads-api/adgroup/). Maybe it's something new?
After noticing the same issue arises when using the Power Manager, I reported a bug and was explained that this is by design, i.e. currently it's not an option available via API. Users who use API should define their goals implicitly by setting the correct bid info (e.g. "Clicks to website" is set by selecting bid_type=CPC or ABSOLUTE_CPM and setting appropriate bid_info.
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!