Add audiences remarketing website visitors to campaign

266 views
Skip to first unread message

testapi...@gmail.com

unread,
Sep 22, 2016, 8:36:14 AM9/22/16
to AdWords API Forum
Hello. I have problem with php remarketing.

and modify its. This script generate TAG and return and this is work fine, but how I can add this remarketing to capaing?

My code view like this:

         
   $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;


Do you have any idea how I can add audiences to campaign when audiences = website visitors?

Shwetha Vastrad (AdWords API Team)

unread,
Sep 22, 2016, 2:00:47 PM9/22/16
to AdWords API Forum
Hi,

To create an audience list that captures everyone who visited a website, you need to create an ExpressionRuleUserList, as shown here. To add this audience to a campaign, you would need to add a CampaignCriterion of type CriterionUserList, similar to how you have created an AdGroupCriterion in your code above. Let me know if this works. 

Regards,
Shwetha, AdWords API Team.

testapi...@gmail.com

unread,
Sep 22, 2016, 4:46:13 PM9/22/16
to AdWords API Forum
I'm sorry but I do not understand you.
My script creates audiences that looks like this:


and creating the appropriate campaigns.


The only thing the script does not do it does not add audiences to campaign. Every time you run functions: AddAudiences($google_campaign_id);
The script adds new audiences but does not assign it to the campaign to which we give id.

testapi...@gmail.com

unread,
Sep 22, 2016, 4:47:36 PM9/22/16
to AdWords API Forum

Shwetha Vastrad (AdWords API Team)

unread,
Sep 22, 2016, 6:34:49 PM9/22/16
to AdWords API Forum
Hi,

Once you have created audiences using the AddAudience.php example, you need to add a CampaignCriterion of type CriterionUserList. Please note that a UserList can only be excluded from a Campaign. To actively target a UserList, you need to create a CriterionUserList at the AdGroup level using the code below: 


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

$adGroupCriterion = new BiddableAdGroupCriterion();
$adGroupCriterion->adGroupId = $adGroupId;
$adGroupCriterion->criterion = $criterionUserList;
$adGroupCriteria[] = $adGroupCriterion;
// Create operation.

$operation = new AdGroupCriterionOperation();
$operation->operand = $adGroupCriterion;
$operation->operator = 'ADD';

$operations[] = $operation;
$result = $adGroupCriterionService->mutate($operations);

The table provided here shows the options available for different criterion types at the campaign and ad group level. 
Reply all
Reply to author
Forward
0 new messages