Google Ads API get AdGroupAds with AdGroupAdLabels

34 views
Skip to first unread message

and...@o44.gr

unread,
Mar 29, 2019, 11:55:03 AM3/29/19
to AdWords API and Google Ads API Forum
Hello,

I am using Google Ads API to get all ad_group_ads that reside within a campaign, as well as all the ad_group_ad_labels that are attached to each ad_group_ad

I tried

SELECT ad_group_ad.ad.id,
    ad_group_ad
.ad.final_urls,
    ad_group_ad
.status,
    ad_group_ad_label
.resource_name,
    campaign
.id
FROM ad_group_ad
WHERE segments
.date DURING YESTERDAY
    AND campaign
.id = $campaignId
    AND ad_group
.status IN ('ENABLED', 'PAUSED')
    AND ad_group_ad
.status IN ('ENABLED', 'PAUSED')
LIMIT
1

receiving the following error.

PROHIBITED_RESOURCE_TYPE_IN_SELECT_CLAUSE

because the AD_GROUP_AD_LABEL resource is incompatible with the AD_GROUP_AD resource.

In the Adwords API I could just do

$selector = new Selector();
$selector
->setFields([
   
'CampaignId',
   
'AdGroupId',
   
'Id',
   
'CreativeFinalUrls',
   
'Status',
   
'Labels',
]);
$reportDefinition
= new ReportDefinition();
$reportDefinition
->setSelector($selector);
$reportDefinition
->setReportType(
   
ReportDefinitionReportType::AD_PERFORMANCE_REPORT
);


and get the list of label names for every AdGroupAd in the response.

Am I missing something here?

Thank you in advance,

Andreas

googleadsapi...@google.com

unread,
Mar 29, 2019, 4:39:44 PM3/29/19
to AdWords API and Google Ads API Forum
Hello Andreas, 

Through the new Google Ads API, you can go up the tree from most specific to general, but you can't go down the tree. So, if I select FROM campaign, I can't select ad_group. However, if I select FROM ad_group, I can select campaign. You can also use the Query Builder to build the request.

Let me know if you have any other questions.

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Reply all
Reply to author
Forward
0 new messages