facebookfacebook-graph-apifacebook-java-api

facebook sdk / graph api - get custom audience current size?


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) -

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 -

  1. Facebook allows creation of look-alike audiences only when the origin audience has at least a 100 members.
  2. 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.


Solution

  • 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}" }