Adwords remarketing type (PHP)

429 views
Skip to first unread message

te...@jyll.tk

unread,
Jul 25, 2016, 5:10:16 AM7/25/16
to AdWords API Forum
Hey :)
I have a problem with the code in php. I would like to create a remarketing based on email. At first I create Audiences by this code:


And next I try to modified this files: 

I think I need Campaign type : "Display Network Only"  so I change line 

    $campaign->advertisingChannelType = 'SEARCH';


to 

    $campaign->advertisingChannelType = 'DISPLAY';

 but aftrer this operation I've get error : 
An error has occurred: [OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[0].operand.networkSetting.targetGoogleSearch; trigger:'DISPLAY', OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[1].operand.networkSetting.targetGoogleSearch; trigger:'DISPLAY']


Do you have any Idea to create Display Campaign ?  

Joyce Lava

unread,
Jul 25, 2016, 6:59:26 AM7/25/16
to AdWords API Forum
Hello,

After updating the advertisingChannelType to DISPLAY, you need to set the targetGoogleSearch and targetSearchNetwork to false and make the targetContentNetwork to true in the NetworkSetting. This should resolve the case. Please refer to this guide for more information about remarketing and audience targeting.

Hope this helps.

Best Regards,
Joyce, AdWords API Team

testapi...@gmail.com

unread,
Jul 25, 2016, 7:35:48 AM7/25/16
to AdWords API Forum
Thanks :)

testapi...@gmail.com

unread,
Jul 25, 2016, 7:09:44 PM7/25/16
to AdWords API Forum
On this moment I have problem with targeting
in php code when I add group to campaign I try to setup target.

 $targetingSetting = new TargetingSetting();
   
// Restricting to serve ads that match your ad group placements.
   
// This is equivalent to choosing "Target and bid" in the UI.
    $targetingSetting
->details[] =
       
new TargetingSettingDetail('USER_INTEREST_AND_LIST', false);
   
// Using your ad group verticals only for bidding. This is equivalent
   
// to choosing "Bid only" in the UI.
   
// $targetingSetting->details[] =
   
//     new TargetingSettingDetail('VERTICAL', true);
    $adGroup
->settings[] = $targetingSetting;


How to set Target setting on Interests & remarketing?
How to set  Interests & remarketing "category" on customer email list?
How to save customer email list as targeting ?

I try to find help in Api docs and network but everywhere is only help whose look like this:

Thank you for help :)

Joyce Lava

unread,
Jul 25, 2016, 10:57:34 PM7/25/16
to AdWords API Forum
Hi,

Apologies for the delayed response. Please see the answers in blue:

How to set Target setting on Interests & remarketing?
      Use the AdGroupService to create the TargetingSettingDetail and set it as the settings (TargetingSetting) of the adGroup. The TargetingSettingDetail should have criterionTypeGroup = USER_INTEREST_AND_LIST and targetAll (true for "Bid only" or false for "Target and bid"). 

How to set  Interests & remarketing "category" on customer email list?
      Apologies but I'm not sure if I understand the question correctly. Could you please elaborate what you need to do on this question? Are you referring to create a ConversionTracker with category REMARKETING? If not, please provide more details on what needs to be done in this concern to properly answer it.

How to save customer email list as targeting?
      Use the AdGroupCriterionService to add each userList as an AdGroupCriterion with criterion of type CriterionUserList. You may refer to the AddKeywords.php to check how to create the BiddableAdGroupCriterion. Just replace the Keyword object with the CriterionUserList object.

testapi...@gmail.com

unread,
Jul 26, 2016, 3:24:44 AM7/26/16
to AdWords API Forum
Hello, of course it's not work :(

 
On the image I try to show you setup whose I need.
Also It's my code:



$campaignId = '632489937';
function AddAdGroupsExample(AdWordsUser $user, $campaignId) {
 
// Get the service, which loads the required classes.
  $adGroupService
= $user->GetService('AdGroupService', ADWORDS_VERSION);


  $numAdGroups
= 2;
  $operations
= array();
 
for ($i = 0; $i < $numAdGroups; $i++) {
   
// Create ad group.
    $adGroup
= new AdGroup();
    $adGroup
->campaignId = $campaignId;
    $adGroup
->name = 'Earth to Mars Cruise #' . uniqid();


   
// Set bids (required).
    $bid
= new CpcBid();
    $bid
->bid =  new Money(1000000);
    $biddingStrategyConfiguration
= new BiddingStrategyConfiguration();
    $biddingStrategyConfiguration
->bids[] = $bid;
    $adGroup
->biddingStrategyConfiguration = $biddingStrategyConfiguration;


   
// Set additional settings (optional).
    $adGroup
->status = 'ENABLED';


   
// Targeting restriction settings. Depending on the criterionTypeGroup
   
// value, most TargetingSettingDetail only affect Display campaigns.
   
// However, the USER_INTEREST_AND_LIST value works for RLSA campaigns -
   
// Search campaigns targeting using a remarketing list.

    $targetingSetting
= new TargetingSetting();
   
// Restricting to serve ads that match your ad group placements.
   
// This is equivalent to choosing "Target and bid" in the UI.
    $targetingSetting
->details[] =

       
new TargetingSettingDetail('USER_INTEREST_AND_LIST', true);

   
// Using your ad group verticals only for bidding. This is equivalent
   
// to choosing "Bid only" in the UI.
   
// $targetingSetting->details[] =
   
//     new TargetingSettingDetail('VERTICAL', true);
    $adGroup
->settings[] = $targetingSetting;



   
// Create operation.
    $operation
= new AdGroupOperation();
    $operation
->operand = $adGroup;
    $operation
->operator = 'ADD';
    $operations
[] = $operation;


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


   
// Create biddable ad group criterion.
    $adGroupCriterion
= new BiddableAdGroupCriterion();
    $adGroupCriterion
->adGroupId = $adGroup;
    $adGroupCriterion
->criterion->CriterionUserList->userListId="404270416";




 
}


 
// Make the mutate request.
  $result
= $adGroupService->mutate($operations);


 
// Display result.
  $adGroups
= $result->value;
 
foreach ($adGroups as $adGroup) {
    printf
("Ad group with name '%s' and ID '%s' was added.\n", $adGroup->name,
        $adGroup
->id);
 
}
}

I need to code kept the same as the setting in the picture, I hope that now it is easier to understand me :)

Joyce Lava

unread,
Jul 26, 2016, 5:09:43 AM7/26/16
to AdWords API Forum
Hello,

Apologies but my PHP knowledge is quite limited. However, seeing the codes, it seems that you have not yet added the CriterionUserList as the AdGroupCriterion. You seemed to be missing the ADD operator for the BiddableAdGroupCriterion. After doing the ADD operator, you need to call the AdGroupCriterionService.mutate operation. 

To avoid confusion, I recommend to do the following:

1. Run the AddAdGroups.php example code with the TargetingSetting as USER_INTEREST_AND_LIST
2. After doing #1, run the AddKeywords.php example code. Use the adGroupId obtained from #1. From the AddKeywords.php example code, just replace the Keyword object to be the CriterionUserList object.

Please let me know the results after doing the steps above.

testapi...@gmail.com

unread,
Jul 27, 2016, 8:33:27 AM7/27/16
to AdWords API Forum
Still not work,On the attachment send my files for you. 

Additionaly it's my console output :)

php AddCampaigns.php

Campaign with name 'Interplanetary Cruise #57989a843a515' and ID '633313135' was added.
Campaign with name 'Interplanetary Cruise #57989a843a69a' and ID '633313138' was added.



php AddAdGroups.php
(At first set ID  633313135)
Ad group with name 'Earth to Mars Cruise #57989ad55901d' and ID '32086324818' was added.
Ad group with name 'Earth to Mars Cruise #57989ad55909f' and ID '32086324938' was added.


php AddKeywords.php
(At first set ID to 32086324818)


PHP Notice:  Undefined index: text in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825
PHP Notice:  Undefined index:  in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825
PHP Fatal error:  Uncaught Error: Cannot access empty property in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php:1825
Stack trace:
#0 test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php(1825): Criterion->__set('', 'mars cruise 579...')
#1 test/googleads-php-lib/examples/AdWords/v201605/BasicOperations/AddKeywords.php(49): Criterion->__set('text', 'mars cruise 579...')
#2 test/googleads-php-lib/examples/AdWords/v201605/BasicOperations/AddKeywords.php(104): AddKeywordsExample(Object(AdWordsUser), '32086324818')
#3 {main}
  thrown in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825


googleadwords.zip

Joyce Lava

unread,
Jul 27, 2016, 10:38:00 PM7/27/16
to AdWords API Forum
Hi,

Thanks for providing the information. I just noticed the following things in your codes:

1. For the AddAdGroups.php, you seemed to be missing the code line for targetingSetting be set on the adGroup (e.g. $adGroup->settings[] = $targetingSetting;). I highlighted the missing line so you could compare it with your code and add this line accordingly.

2. For the AddKeywords.php, you seemed to be adding the Keyword object as criterion of the adGroup. As informed in my previous post, you may use this example code but you need to replace the Keyword object to CriterionUserList object and set it as the criterion of the BiddableAdGroupCriterion. You may try to do the following code to set the CriterionUserList object instead of Keyword:

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

$criterionUserList = new CriterionUserList();
$criterionUserList->userListId = Id of the CriterionUserList you created using the AddCrmBasedUserList.php example code.


// Create biddable ad group criterion.
$adGroupCriterion = new BiddableAdGroupCriterion();
$adGroupCriterion->adGroupId = Your adGroupId;
$adGroupCriterion->criterion = $criterionUserList;

// Create operation.
$operation = new AdGroupCriterionOperation();
$operation->operand = $adGroupCriterion;
$operation->operator = 'ADD';
$operations[] = $operation;
// Make the mutate request.
$result = $adGroupCriterionService->mutate($operations);

After that, you may want to change the attributes (e.g. text, matchTye, etc.) in the printf as these attributes belong to the Keyword object. You may want to change them to print the attributes of the adGroupCriterion or the CriterionUserList object.

Hope this helps.

Joyce Lava

unread,
Jul 27, 2016, 10:43:50 PM7/27/16
to AdWords API Forum
Hi,

Additionally, I recommend to use your test account in trying the above suggestions.

Thanks,
Joyce, AdWords API Team

testapi...@gmail.com

unread,
Jul 28, 2016, 3:22:22 AM7/28/16
to AdWords API Forum
There is still the same error

PHP Notice:  Undefined index: text in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825
PHP Notice:  Undefined index:  in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825
PHP Fatal error:  Uncaught Error: Cannot access empty property in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php:1825
Stack trace:
#0 test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php(1825): Criterion->__set('', 'mars cruise 579...')
#1 test/googleads-php-lib/examples/AdWords/v201605/BasicOperations/AddKeywords.php(53): Criterion->__set('text', 'mars cruise 579...')
#2 test/googleads-php-lib/examples/AdWords/v201605/BasicOperations/AddKeywords.php(108): AddKeywordsExample(Object(AdWordsUser), '32094082578')
#3 {main}
  thrown in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825

Joyce Lava

unread,
Jul 28, 2016, 4:33:35 AM7/28/16
to AdWords API Forum
Hi,

Just to confirm, have you tried the previous suggestions? If so, could you please provide the SOAP request and response? This will help investigate the case further. Please make sure to click on reply privately to author when replying.

testapi...@gmail.com

unread,
Jul 28, 2016, 5:10:00 AM7/28/16
to AdWords API Forum



    $keyword
= new CriterionUserList();
    $keyword
->text = 'mars cruise ' . uniqid();
    $keyword
->matchType = 'BROAD';

On this code is error

I try to place exit in every line in code and this code run error

testapi...@gmail.com

unread,
Jul 28, 2016, 5:11:36 AM7/28/16
to AdWords API Forum
When I comment this code I'v got error:

An error has occurred: [AdGroupCriterionError.CANNOT_MODIFY_URL_FIELDS_WITH_DUPLICATE_ELEMENTS @ operations[0].operand, AdGroupCriterionError.CANNOT_MODIFY_URL_FIELDS_WITH_DUPLICATE_ELEMENTS @ operations[1].operand, AdGroupCriterionError.CANNOT_MODIFY_URL_FIELDS_WITH_DUPLICATE_ELEMENTS @ operations[2].operand, AdGroupCriterionError.CANNOT_MODIFY_URL_FIELDS_WITH_DUPLICATE_ELEMENTS @ operations[3].operand, AdGroupCriterionError.CANNOT_MODIFY_URL_FIELDS_WITH_DUPLICATE_ELEMENTS @ operations[4].operand]

testapi...@gmail.com

unread,
Jul 28, 2016, 5:56:52 AM7/28/16
to AdWords API Forum
Now works, accidentally duplicated by criteria thanks you for help me :)

You are super :D

Joyce Lava

unread,
Jul 28, 2016, 6:11:01 AM7/28/16
to AdWords API Forum
Hello,

Glad to hear you found the fix.

testapi...@gmail.com

unread,
Jul 29, 2016, 9:54:28 AM7/29/16
to AdWords API Forum
Hello :)
I edited this file to report my campaign etc. and it's work perfectly 
/examples/AdWords/v201605/Reporting/DownloadCriteriaReport.php


but How I do make report for only one Ad ?

Anthony Madrigal

unread,
Jul 29, 2016, 2:25:58 PM7/29/16
to AdWords API Forum
Hello,

Since this is a new question, could you please post in a new thread?

Thanks,
Anthony
AdWords API Team
Reply all
Reply to author
Forward
0 new messages