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']
$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;
$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);
}
}
$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);
PHP Notice: Undefined index: text in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825PHP Notice: Undefined index: in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php on line 1825PHP Fatal error: Uncaught Error: Cannot access empty property in test/googleads-php-lib/src/Google/Api/Ads/AdWords/v201605/AdGroupCriterionService.php:1825Stack 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
$keyword = new CriterionUserList();
$keyword->text = 'mars cruise ' . uniqid();
$keyword->matchType = 'BROAD';
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]