Hello Team,
I want to add/set particular "location's Income Tier". To achieve this I am using this code:
// Get the service, which loads the required classes.
$clientId = (float) $clientid; //correct Client Id
$campaignId = (float) $campaignId; // correct campaignId
$location = (float) $location; // Correct locationId
$tier = 'TIER_1';
$user->SetClientCustomerId($clientId);
$campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
$campaignCriteria = array();
// Location Groups criteria. These represent targeting by household income
// or places of interest. The IDs can be found in the documentation or
// retrieved with the LocationCriterionService.
// Tiers are numbered 1-10, and represent 10% segments of earners.
// For example, TIER_1 is the top 10%, TIER_2 is the 80-90%, etc.
// Tiers 6 through 10 are grouped into TIER_6_TO_10.
// Other valid options: AIRPORT, UNIVERSITY.
$tier = new IncomeOperand($tier);
$Loc = new GeoTargetOperand(array($location)); // Miami, FL
$firstGroup = new LocationGroups();
$firstGroup->matchingFunction = new FeedFunction('AND', $tier, $Loc);
$campaignCriteria[] = new CampaignCriterion($campaignId, null, $firstGroup);
/*
if ($locationFeedId !== null) {
// Distance targeting. Area of 10 miles around targets above.
$radius = new ConstantOperand();
$radius->type = 'DOUBLE';
$radius->unit = 'MILES';
$radius->doubleValue = 10.0;
$distance = new LocationExtensionOperand($radius);
$secondGroup = new LocationGroups();
$secondGroup->feedId = intval($locationFeedId);
$secondGroup->matchingFunction = new FeedFunction('IDENTITY', $distance);
$campaignCriteria[] =
new CampaignCriterion($campaignId, null, $secondGroup);
}
*/
// Create operations.
$operations = array();
foreach ($campaignCriteria as $campaignCriterion) {
/* echo '<pre>';
print_r($campaignCriterion);die(); */
$operations[] = new CampaignCriterionOperation($campaignCriterion, 'ADD');
}
/* // Add a negative campaign criterion.
$negativeKeyword = new Keyword();
$negativeKeyword->text = 'jupiter cruise';
$negativeKeyword->matchType = 'BROAD';
$negativeCriterion = new NegativeCampaignCriterion();
$negativeCriterion->campaignId = $campaignId;
$negativeCriterion->criterion = $negativeKeyword;
$operations[] = new CampaignCriterionOperation($negativeCriterion, 'ADD');
*/
// Make the mutate request.
return $result = $campaignCriterionService->mutate($operations);
But this code giving me following error:
<br />
<b>Fatal error</b>: Uncaught SoapFault exception: [soap:Server] [CriterionError.CANNOT_TARGET_CRITERION
@ operations[0].operand.criterion.matchingFunction] in /home/bergstromdev/public_html/Google/Api/Ads
/Common/Lib/AdsSoapClient.php:216
I am not getting what it means and how to resolve this?
Please reply & guide me asap to resolve this error.
Thanks & Regards
Sachin Kumar