Question - is there a way to get the current size of an audience from facebook? (if so, Java SDK details would be appreciated)
Why do I need this? - I'm looking to achieve the following in facebook using the java sdk (tech is irrelevant here - same issue regardless of api) -
Create a custom audience using a bunch of email ids.
Follow that with creating a look-alike audience based on the new audience above.
Complication - Now the above are pretty straightforward as individual steps and we are able to that with no issue. Trouble comes due to the following -
Facebook allows creation of look-alike audiences only when the origin audience has at least a 100 members.
Also, Facebook take a little time processing the first list (looking up matches etc. I guess) during which time the "size"of the custom audience is low (like 20 etc.). If I check back in like an hour or so, it would have updated with all the matches, and the size is now as expected.
Due to the above, if I follow the "create custom audience" call immediately with a "create look-alike audience" call, it will fail with the error below (have tried it multiple times) -
{
"error":{
"message":"(#1234) Source Audience is Too Small:
There are not enough people in your source in the country you chose.
Please choose a country that includes at least 100 people in your source.",
"type":"Exception-type",
"code": 1234,
"error_subcode":5678,
"fbtrace_id":"fb-trace-id"
}
}
If I try the look alike audience creation a while later, it works, cos by then the audience is processed (at least partially) and the size has gone > 100.
Solutions explored -
So one obvious way to solve this is to introduce a delay in creating the lookalike audience after having created the initial custom audience. This has its issues (most important is that it is guess work vs. a solid hand-shake).
Therefore (out of my innate need to have control) I'd like to "know" when the custom audience is ready (hence the original question above) so I can create the look-alike audience - am looking for help to see how this can be achieved?
I've looked thru facebook graph api docs here (http://restfb.com/javadoc/), scanned facebook forums here (https://developers.facebook.com/bugs/) to see if the CustomAudience has (or if there is another API) that gives the current size of an audience, but haven't found any. Any help is appreciated.
Thank you.
I guess this is already not relevant, but anyway.
You can make a GET request with a parameter "fields" set: https://graph.facebook.com/v2.10/{custom_audience_id}?fields=["approximate_count", "operation_status"]
The result you'll get shows approximate count of the CA and status (is the CA ready)
{
{
"approximate_count": 20,
"operation_status": {
"code": 200,
"description": "Normal"
},
"id": "{custom_audience_id}"
}
Related
lookalike audience showing disabled on audience dashboard while creating through API and showing a message "Lookalikes that contain locations are being retired and can't be used in new campaigns.
", Other hand when we creating lookalike audience without location than API giving error "(#2654) Missing Locations in Lookalike Spec: The lookalike spec must contain one of location_spec or country field to create a lookalike."
This seems to be bug on Facebook API. I also facing this issue as well. It seems like Facebook is going to remove country from lookalike spec in the future so any lookalike created with country in the spec got disabled. However, an api still require country parameter in order to create lookalike. So the best advise that I can give is to ask them to remove your account from test group by posting in the bug report like many others.
Example of bug reports
Spec should be in a similar format
"lookalike_spec": {"type": "similarity", "country": "US"}, "origin_audience_id": "123"
I am using Facebook PHP SDK, and trying to create Audience of Custom TYPE from Marketing API, and I am getting following Error:
You'll need to agree to the Custom Audience terms before you can
create or edit an audience of CUSTOM type. To accept, go to
https://business.facebook.com/ads/manage/customaudiences/tos/?act=129260934125705.
Even though I have already accepted the term, I am still getting the error for accepting the terms.
Please find attached screenshot for Terms Acceptance.. Terms & Condition Accepted Screenshot
I would recommend checking the status of tos_accepted via Graph API explorer. You can also use it to debug your Audience Creation calls.
You can check if a Business has signed their Custom Audience terms of service, by making a GET call to an ad account owned by that Business. The ad account can’t be acting on behalf of another business, or be shared. The GET call is:
GET act_<AD_ACCOUNT_ID>?fields=tos_accepted
A sample response looks like this:
{
"tos_accepted": {
"custom_audience_tos": 1 // this means the terms were signed
},
"id": "act_<AD_ACCOUNT>"
}
Check full docs about TOS here
A bit more info on Custom Audiences
Thanks Artyom Kovalyov.. I have checked the graph API explorer, and this is what I get.
{
"tos_accepted": {
"web_custom_audience_tos": 1,
"custom_audience_tos": 1,
"value_based_custom_audience_tos": 1
},
"id": "act_129260934125705"
}
Please check and let me know if I can do something else to fix the error that I am getting..
It seems ok Vishal. Have you tried to create this same Audience via graph explorer? The ways to go from here are either filing an FB direct support case for your app, they are not usually fast to reply and not every customer is whitelisted for that.
Another assumption is if you try to do it on behalf of your customer with their account, it might be that they have to accept TOS, not you.
FB has a huge amount of setting and from the info, you provide it's pretty hard to tell what exactly fails.
After many tries, I'm not getting how we can use the Facebook API to create a simple Ad based on a Post (and it's creative) like it is possible in the Business Manager.
For example, my last attempt failed due to a problem with Instagram:
Facebook API: Instagram Account Is Missing
If there is anybody that has been able to create a basic Ad (within a given or new AdSet) based on a Post, please help me. I've seen many questons like this (especially regarding the Instagram problem) and now I'd like to have a working solution.
What exact requests have to be done or isn't it possible at all?
THe Instagram placement is added by default in the targeting, so if you want to skip it you need to specify in the targeting field when creating the adSet in the publisher field:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook'],
facebook_positions: ['feed', 'right_hand_column'],
device_platforms: ['mobile', 'desktop']
}
If you want to publish on Instagram also you should also provide an instagram actor ID: The AdsCreative should contain an extra field named instagram_actor_id also remember to add Instagram in the related targeting:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook','instagram'],
facebook_positions: ['feed', 'right_hand_column'],
instagram_positions: ['stream', 'story'],
device_platforms: ['mobile', 'desktop']
}
Reference:
https://developers.facebook.com/docs/marketing-api/guides/instagramads
https://developers.facebook.com/docs/marketing-api/guides/instagramads/ads_management/
https://developers.facebook.com/docs/marketing-api/targeting-specs/#placement
Let me know if you need more info or an answer or your other question about Instragam
If you go to business manager of facebook, then go to the "All Audiences", then under the "Audiences" tab, you will see a "Filters" button right beside the "Create Audience" button. Now my question is, which part the json data being provided by the facebook apis should I based the data that I should pull out based from these filters ?
- Recently Used
- In Active Adverts
- Action Needed
- Shared
Because unlike the "ready" and "not ready" status, those four filters that I mentioned are not straight forward where I can just look for the numbers from the returned json data. so how ?
Most likely, not all of this information is available through the API.
However, if you take a look at the following doc, you can see some reelvant fields that may help:
https://developers.facebook.com/docs/marketing-api/reference/custom-audience
Most likely you can use the field operation_status to look at whether an audience needs action.
For whether it's shared, take a look ad the edge adaccounts which will let you see the ad accounts this audience has been shared with.
For recently used, you'll probably have to look at the edge ads and review the status of the ads.
To save having to make multiple requests, you can take a look at field expansion in the Graph API, which will let you query for fields of objects in results using a single request:
https://developers.facebook.com/docs/graph-api/using-graph-api#fieldexpansion
We have listing and details page for mobile, desktop, android and ios?
We have two apis- one for listing and other for details of those listings. So one api is assosiated with other.
listing api looks like:
/api/books/?price=100-300
details api looks like:
/api/book/{bookId}
listing api in response sends back details api link for each listing:
For example:
Request:
/api/books/?price=100-300
will have Response:
{
"books":[
{
"id": 1,
"price": 120,
"pages": 400,
"detailsUrl": "/api/book/{bookId}"
}
]
}
The problem is, should I send detailsUrl with each listing or let all the clients create this? Since they have bookId, they can create it.
What is considered to be best practise considering the url params in details api url may get added in future, api may be versioned and all other possibilities for widely used apis?
I'd put my money on creating the link.
There is a perfect explanation why putting id is not enough
DO NOT include just an entity's ID (such as 12) in a response, because
that way you're forcing clients to put together resource URIs
themselves. In order to do that, they would need to have prior
knowledge of what URIs there are, and you're losing control over the
URI space on the server side.
I recommend to read the entire, linked text (approved answer), it's very detailed and got nice resources. As the author mentioned, there is a popular convention how to make connections between resources - HAL. Consider this instead of detailsUrl.
Even if a link to the resource is obvious right now and you decided to put id alone, in other resources after some time it won't be so simple and you will be forced to specify full URL. Then your API won't be consistent. Experience has taught me it's always easier and better for maintenance to send back full link.