Adwords将再营销网站访问者添加到camapign

时间:2016-09-22 16:50:01

标签: php google-adwords

我的php代码有一个问题。我创建广告系列并从PHP创建受众标记(再营销=>网站访问者=>代码)。 问题是当我尝试将观众纳入广告系列时。我正在使用的代码: github example

我的代码视图如下:

 $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
           $adGroupId = $group_id;


            $operations = array();
           $campaign = new Campaign();
           $campaign->id = $google_data['google_id'];

            $campaign->advertisingChannelType = 'DISPLAY';

            $networkSetting = new NetworkSetting();
           $networkSetting->targetGoogleSearch = false;
           $networkSetting->targetSearchNetwork = false;
           $networkSetting->targetContentNetwork = true;
           $campaign->networkSetting = $networkSetting;

            $operation = new CampaignOperation();
           $operation->operand = $campaign;
           $operation->operator = 'SET';
           $operations[] = $operation;

            $result = $campaignService->mutate($operations);

            $return_array['id'] = $result->value[0]->id;


 $userListService = $user->GetService('AdwordsUserListService', ADWORDS_VERSION);


  $conversionTrackerService =
     $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
 $conversionType = new UserListConversionType();
 $conversionType->name = $name . uniqid();



  $userList = new BasicUserList();
 $userList->name = $name . uniqid();
 $userList->conversionTypes = array($conversionType);
 $userList->status = 'OPEN';
 $userList->membershipLifeSpan = $day;



  $operation = new UserListOperation();
 $operation->operand = $userList;
 $operation->operator = 'ADD';
 $operations = array($operation);
 $result = $userListService->mutate($operations);
 $userList = $result->value[0];
 $static_user_id = $userList->id;
// print_r($userList->id);
// exit;

  sleep(1);
 $selector = new Selector();
 $selector->fields = array('Id');
 $selector->predicates[] =
     new Predicate('Id', 'IN', array($userList->conversionTypes[0]->id));

  $page = $conversionTrackerService->get($selector);


  $conversionTracker = $page->entries[0];
$tag = $conversionTracker->snippet;


$audience_id = $userList->conversionTypes[0]->id;



            $campaignId = $return_array['id'];
           $adGroupService = $user->GetService('AdGroupService', ADWORDS_VERSION);

            $operations = array();
           $adGroup = new AdGroup();
           $adGroup->id = $google_data['google_group_id'];
           $adGroup->campaignId = $campaignId;





            $targetingSetting = new TargetingSetting();
           $targetingSetting->details[] = new TargetingSettingDetail('PLACEMENT', false);
           $adGroup->settings[] = $targetingSetting;

            $operation = new AdGroupOperation();
           $operation->operand = $adGroup;
           $operation->operator = 'SET';
           $operations[] = $operation;

            $result = $adGroupService->mutate($operations);
           $return_array['id_group'] = $result->value[0]->id;


            $adGroupId = $return_array['id_group'];


            $adGroupCriterionService = $user->GetService('AdGroupCriterionService', ADWORDS_VERSION);




            $criterionUserList = new CriterionUserList();
           $criterionUserList->id = $static_user_id;
           $criterionUserList->type = "USER_LIST";


            $operations = array();
           $adGroupCriterion = new BiddableAdGroupCriterion();
           $adGroupCriterion->adGroupId = $adGroupId;
           $adGroupCriterion->criterion = $criterionUserList;
           $adGroupCriteria[] = $adGroupCriterion;

            $operation = new AdGroupCriterionOperation();
           $operation->operand = $adGroupCriterion;
           $operation->operator = 'SET';
           $operations[] = $operation;

            $result = $adGroupCriterionService->mutate($operations);

            $return_array['remarketing_email'] = $result->value[0]->criterion->id;

当我运行此代码时,我有输出:

  

发生了错误:215 [EntityNotFound.INVALID_ID @ operations [0] .operand.criterion.id;触发: 'CriterionId {ID = 414978678}']

0 个答案:

没有答案