Google Ads: Querying language data from campaign_criterion

36 views
Skip to first unread message

integrations bidalgo

unread,
Jun 23, 2019, 3:54:33 AM6/23/19
to AdWords API and Google Ads API Forum
Hello,
I'm querying language data from campaign_criterion object (Google Ads) like this:

SELECT campaign_criterion.status,campaign.id,campaign_criterion.criterion_id,campaign_criterion.language.language_constant FROM campaign_criterion

After getting results, I'm looping over GoogleAdsRows and trying to obtain language data like this:

$languageConstant = $googleAdsRow->getLanguageConstant();
/** @var LanguageConstant $languageConstant */

$code = $languageConstant !== null ? $languageConstant->getCodeValue(): '';
$name = $languageConstant !== null ? $languageConstant->getNameValue(): '';

But no data is returned ($languageConstant is null).
What is wrong here?


Google Ads API Forum Advisor Prod

unread,
Jun 24, 2019, 12:03:39 AM6/24/19
to adwor...@googlegroups.com
Hi,

So I can better investigate, could you confirm if you have indeed explicitly targeted specific language criteria? By default, all languages are targeted, however, statistics for those languages will not be returned unless you have explicitly targeted them using the CampaignCriterionService.

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UCZ1Uv:ref

integrations bidalgo

unread,
Jun 24, 2019, 3:04:01 AM6/24/19
to AdWords API and Google Ads API Forum
Hi Peter,

Not sure what do you mean by "explicitly targeted", but languages targeting was created by CampaignCriterionService (in AdWords API, by campaignCriterionService->mutate method). 

Google Ads API Forum Advisor Prod

unread,
Jun 24, 2019, 4:50:52 AM6/24/19
to adwor...@googlegroups.com
Hi,

My apologies for the confusion. We currently do not have a specific PHP example for what you are looking for. However, you can refer to this PHP example on how to retrieve campaign targeting criteria.

As for retrieving the language constant, you may try in PHP something similar to this : getLanguage -> getLanguageConstantValue. Let me know if this works for you.

Best regards,

integrations bidalgo

unread,
Jun 24, 2019, 10:59:15 AM6/24/19
to AdWords API and Google Ads API Forum
Hi,

Unfortunately, I can't get language code or language name using getLanguage -> getLanguageConstantValue
 I saw that they can be retrieved from LanguageConstant object, but there is no method allowing to get LanguageConstant from CampaignCriterion.
$googleAdsRow->getCampaignCriterion()->getLanguage()->getLanguageConstant() returns string and not LanguageConstant object...
Please  advise.
Reply all
Reply to author
Forward
0 new messages