Java how to fetch campaign labels using the new api

32 views
Skip to first unread message

Oly

unread,
Jun 6, 2022, 5:57:17 AM6/6/22
to Google Ads API and AdWords API Forum
I am running this query

SELECT
       campaign.name,
       campaign.labels,
       campaign.status,
       metrics.impressions,
       metrics.clicks,
       metrics.cost_micros,
       segments.date
     FROM campaign
     WHERE segments.date DURING LAST_7_DAYS
     AND campaign.status = 'ENABLED'


If I print the return rows from getResultList I can see I have the labels, how ever I can figure out how to get the label data.

It seems there should be something like getCampaignLabels or getLabels the example I found suggests row.getLabel.getName how ever this returns back, it also seems singular when I may have multiple rows.

Is there something special I should be doing ?
The closest I can find is this example but it selects from labels table not the campaign table.


Can anyone offer any suggestions to steer me in the right direction ?




Google Ads API Forum Advisor

unread,
Jun 6, 2022, 6:45:49 AM6/6/22
to adwor...@googlegroups.com

Hi Oly,
 

Thanks for reaching out to the Google Ads API Support team.


With regard to your concern, so our team can better check this concern, could you provide the complete Ads API logs (request and response with request-id) to further investigation on this? You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.
 

However, with regards to this concern, "how to get the label data." You may refer to this documentation Label. These labels allow you to categorize your campaigns, ad groups, ads, and keywords. To add a campaign and get campaign labels, you may refer to this guide.
 

Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bcZCK:ref

Oly

unread,
Jun 6, 2022, 7:48:09 AM6/6/22
to Google Ads API and AdWords API Forum
Hi adsapi,

I have seen those links but they work differently so it does not really answer the question, the last example select from the label so each row is a label where as when you select from campaign it would be multiple campaigns associated to a campaign.

The Label example calls this googleAdsRow.getLabel().getName() which I can indeed call but it returns a blank string "" as previously mentioned I can see the label resources if i print googleAdsRow so I know the data is there I just cant access, seems it is either a but or getLabel is refering to a different label type and not a campaign label, also seems it should be getLabels not getLabel as the association is one to many.

Regards
Oly
Reply all
Reply to author
Forward
0 new messages