2

I'm using https://github.com/facebook/facebook-php-ads-sdk in Laravel PHP to add users to a Facebook Custom Audience. The request goes fine, but after a few days of adding users, nothing gets matched. If I manually add users to that same audience, it's fine, users are matched. So I guess I have an issue with hashing or data format.

Here is my code:

    $hashedPhone = hash(HashNormalizer::HASH_TYPE_SHA256, "+4" . $phone);
    $hashedCountryCode = hash(HashNormalizer::HASH_TYPE_SHA256, "RO");
    $audiences = array([$hashedPhone, $hashedCountryCode]);

    //add to Facebook audience
    $schema = array(
        CustomAudienceMultikeySchemaFields::PHONE,
        CustomAudienceMultikeySchemaFields::COUNTRY
    );
    if (count($audiences) > 0) {
        $audience = new CustomAudienceMultiKey($audienceId);
        // always hash before this, the framework hashing doesn't work properly !!!
        $response = $audience->addUsers($audiences, $schema, true, true);

        /*
        print_r($response);
        $audience->read(array(CustomAudienceFields::APPROXIMATE_COUNT));
        echo "Estimated Size:" . $audience->{CustomAudienceFields::APPROXIMATE_COUNT} . PHP_EOL;
        */
    }

And here is the Custom Audience history (rows are added, but nothing gets matched): enter image description here

I'm only trying to match users by phone and country code. I've read the API documentation (https://developers.facebook.com/docs/marketing-api/audiences-api)... not sure what's wrong or missing.

Is there a way to see what rows were added into the Custom Audience, so I can debug and do data validation / hashing / format?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Andrei J
  • 35
  • 5

0 Answers0