setting language parameter in new campaign class

116 views
Skip to first unread message

Oleg Disrupt

unread,
Nov 15, 2021, 5:04:06 AM11/15/21
to AdWords API and Google Ads API Forum
Hello,
I want to add the language that I want when i created the new campaign.
for example
$campaign = new Campaign([
'name' => 'campaign1',
'language' => english
]);
I can't see 'language' parameter in campaign class.

Can you help me?
Regards
oleg

Google Ads API Forum Advisor

unread,
Nov 15, 2021, 12:26:28 PM11/15/21
to ol...@disrupt.social, adwor...@googlegroups.com
Hi Oleg,

There isn't a way to set the language of a campaign through the CampaignService. However, you can set language as a campaign criterion using the CampaignCriterionService.

Regards,
Matt
Google Ads API Team


Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Matt
Google Ads API Team
 
 

ref:_00D1U1174p._5004Q2R93oS:ref
Message has been deleted

Filip Pećanac

unread,
Nov 16, 2021, 8:34:42 AM11/16/21
to AdWords API and Google Ads API Forum
Hi Oleg,

In PHP I have used the following code to add language(s):

$campaignResourceName = ResourceNames::forCampaign($customerId, $campaignId);
$campaignCriterionOperations = [];

$campaignCriterion = new CampaignCriterion([
'campaign' => $campaignResourceName,
'type' => CriterionType::LANGUAGE,
'language' => new LanguageInfo([
'language_constant' => ResourceNames::forLanguageConstant($languageId),
]),
]);

$campaignCriterionOperation = new CampaignCriterionOperation();
$campaignCriterionOperation->setCreate($campaignCriterion);
$campaignCriterionOperations[] = $campaignCriterionOperation;

$campaignCriterionServiceClient = $this->googleAdsClient->getCampaignCriterionServiceClient();
$campaignCriterionServiceClient->mutateCampaignCriteria(
$customerId,
$campaignCriterionOperations
);

I hope it helps you :)

Regards,
FIlip

Google Ads API Forum Advisor

unread,
Nov 16, 2021, 1:22:37 PM11/16/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

Thank you for providing your own solution. 

Oleg, please also note that there is a code example that makes use of the CampaignCriterionService to add campaign targeting criteria.
Reply all
Reply to author
Forward
0 new messages