Adding labels to campaign

180 views
Skip to first unread message

ad...@armis.tech

unread,
Jan 20, 2017, 10:08:03 AM1/20/17
to AdWords API Forum
Hi everyone.

I am currently working on a python script to create campaigns, adgroups and ads and I need to create labels and assign those to campaigns.
I have created text labels but I can't find a way to attach a label to a campaign. I've tried the following code:

{'name':tup[0], 'status':'PAUSED', 'advertisingChannelType':'SEARCH', 'biddingStrategyConfiguration':
            {'biddingStrategyType':'MANUAL_CPC',},
            'budget':{'budgetId':tup[1]},
            'labels':{'labelId':tup[2],},
            'networkSetting':{'targetGoogleSearch':'true', 'targetSearchNetwork':'true', 'targetContentNetwork':'false', 'targetPartnerSearchNetwork':'false'},}

Of course I got an error: suds.TypeNotFound: Type not found: 'labelId'
I can't find any example where a campaign is created with a label id so is it even possible or do I have to create a campaign then assign it a label ?
And if you have the solution, a code example would be nice.

Thank you for your help.

Shwetha Vastrad (AdWords API Team)

unread,
Jan 20, 2017, 12:35:32 PM1/20/17
to AdWords API Forum
Hi Adam,

When creating a campaign, you need to provide the list of labelIds that you want to apply in the labels field as shown below:

'labels': [
              {
                  'id': LABEL_ID
              }
          ] 

If you want to apply labels after the campaigns have been created, you need to use CampaignService.mutateLabel() method to add a label. The add_campaign_labels.py Python example demonstrates how to add a label to multiple campaigns.

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages