如何添加用户到Facebook自定义观众 [英] How to add user to facebook custom audience

查看:207
本文介绍了如何添加用户到Facebook自定义观众的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码向用户添加用户

I am trying to add user to custom audience using following code

$audience = new CustomAudience($custom_audience_id);
$audience->addUsers(array(trim($mailAddress)), CustomAudienceTypes::EMAIL);

$users = array(
 array('fname', 'lname', 'someone@example.com'),
 array('fnamenew', 'lnamenew', 'someone_new@example.com'),
);

$schema = array(
  CustomAudienceMultikeySchemaFields::FIRST_NAME,
  CustomAudienceMultikeySchemaFields::LAST_NAME,
  CustomAudienceMultikeySchemaFields::EMAIL,
);

$audience = new CustomAudienceMultiKey(<CUSTOM_AUDIENCE_ID>);

$audience->addUsers($users, $schema);

但是我在两个代码中都收到错误

But I am getting error in both codes

(#2650) Failed to update the custom audience: This audience was created from data source EVENT_BASED.WEB_PIXEL_HITS, which does not support data source FILE_IMPORTED.HASHES_OR_USER_IDS

以下用于创建自定义受众的代码。

Following code I am using to create custom audience.

$audience = new CustomAudience(null, $accountId);
        $audience->setData(array(
          CustomAudienceFields::NAME            => $associative_arr['name'],
          CustomAudienceFields::PIXEL_ID        => $associative_arr['pixelId'],
          CustomAudienceFields::DESCRIPTION     => $associative_arr['description'],
          CustomAudienceFields::RETENTION_DAYS  => $associative_arr['retensionDays'],  
          CustomAudienceFields::SUBTYPE         => CustomAudienceSubtypes::WEBSITE,
          CustomAudienceFields::RULE            => array('url' => array('i_contains' => $associative_arr['websiteUrl'])),
          CustomAudienceFields::PREFILL         => $associative_arr['prefill'],
          CustomAudienceFields::DATA_SOURCE     => array('EVENT_BASED' => 'WEB_PIXEL_HITS')
        ));         
        $audience->create();

任何建议如何解决这个问题?

Any suggestion how I can solve this?

推荐答案

您只能将用户添加到通过电子邮件创建的自定义受众群体。虽然您在创建受众群体中显示的代码基于您网站上的用户活动。
您可以按照此文档通过电子邮件创建自定义受众:
https://developers.facebook.com/docs/marketing-api/audiences-api#build

You can only add user to the custom audience that is created through emails, While the code you shown in creating audience is based on user activities on your website. You can follow this doc to create your custom audience through email: https://developers.facebook.com/docs/marketing-api/audiences-api#build

然后在您的广告中,您可以组合两个观众(从电子邮件和/从

And then in your ads, you can combine the two audience (From emails and/ from

这篇关于如何添加用户到Facebook自定义观众的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆