将自定义受众群体链接到Adset

问题描述:

我使用Facebook Marketing Api创建广告和自定义受众群体。我怎么都找不到一种方法将创建的自定义受众群体链接到AdSense。 以下是github中的示例。目前,我只能创建包含兴趣和地理位置的Adsets。将自定义受众群体链接到Adset

如以下示例所示,我们只能根据兴趣和地理位置进行定位。

$results = TargetingSearch::search(
    $type = TargetingSearchTypes::INTEREST, 
    $class = null, 
    $query = 'facebook'); 
// we'll take the top result for now 
$target = (count($results)) ? $results->current() : null; 
echo "Using target: ".$target->name."\n"; 
$targeting = new TargetingSpecs(); 
$targeting->{TargetingSpecsFields::GEO_LOCATIONS} 
    = array('countries' => array('GB')); 
$targeting->{TargetingSpecsFields::INTERESTS} = array(
    array(
     'id' => $target->id, 
     'name' => $target->name, 
    ), 
); 


$adset = new AdSet(null, $account->id); 
$adset->setData(array(
    AdSetFields::NAME => 'My First AdSet', 
    AdSetFields::CAMPAIGN_ID => $campaign->id, 
    AdSetFields::STATUS => AdSet::STATUS_ACTIVE, 
    AdSetFields::DAILY_BUDGET => '150', 
    AdSetFields::TARGETING => $targeting, 
    AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::REACH, 
    AdSetFields::BILLING_EVENT => BillingEvents::IMPRESSIONS, 
    AdSetFields::BID_AMOUNT => 2, 
    AdSetFields::START_TIME => 
    (new \DateTime("+1 week"))->format(\DateTime::ISO8601), 
    AdSetFields::END_TIME => 
    (new \DateTime("+2 week"))->format(\DateTime::ISO8601), 
)); 
$adset->validate()->create(); 
echo 'AdSet ID: '. $adset->id . "\n"; 

我的要求是一个自定义的观众直接链接到Adset,例如 AdSetFields :: CUSTOMAUDIENCE => $ audienceid

这是ATLEAST可能吗?如果不能如何将我们创建的自定义受众与Adset关联起来?

您可以使用字段custom_audiences,该字段接受一组要定位的自定义受众群体。我不知道,如果实际需要的名字也,但它在所有的例子:

$targeting->{TargetingSpecsFields::CUSTOM_AUDIENCES} = array(
    array(
    'id' => <AUDIENCE_ID>, 
    'name' => <AUDIENCE_NAME>, 
), 
); 

targeting doc并搜索“瞄准定制观众&合作伙伴类别”

+1

感谢保罗,这是什么我一直在寻找。一些我在定位规范文档中错过了这一部分。 – Chamindar2002

+0

请您也可以分享一个java的例子, 我发现遍布Facebook文档,但没有找到。 –