Check if Label already assigned to a Keyword

34 views
Skip to first unread message

Shree

unread,
Jan 21, 2015, 10:51:37 AM1/21/15
to adwor...@googlegroups.com
Hi,
I am using Adwords API in Python.
I want to check if a Label 'ABC' is already assigned to a particular keyword 'KeywordA'. 
I will check if Label 'ABC' is present in the Page entries returned by 'get' method of AdGroupCriterionService
How will I write a serviceSelector for specifying CriterionId for a keyword. I am trying with following things -

I have LabelId, adGroupId and CriterionId as input for serviceSelector -

    ad_group_criterion_service = client.GetService('AdGroupCriterionService', version='v201409')

    serviceSelector = {
            'fields': ['Labels'],
            'predicates': [{
                            'field': 'Labels',
                            'operator': 'CONTAINS_ANY',
                            'values': [LabelId]
                            },
                            {
                            'field': 'AdGroupId',
                            'operator': 'EQUALS',
                            'values': [adGroupId]
                            },
                            {
                            'field': 'CriterionUse',
                            'operator': 'EQUALS',
                            'values': ['BIDDABLE']
                            }]
                            # {                                *** How to write this part ?? I want to set Keyword --> Id
                            # 'field': 'Criterion',
                            # 'operator': 'EQUALS',
                            # 'values': [{'Id': CriterionId}]
                            # }]
   
                }       
    page = ad_group_criterion_service.get(serviceSelector)

Michael Cloonan (AdWords API Team)

unread,
Jan 22, 2015, 10:51:40 AM1/22/15
to adwor...@googlegroups.com
Hello,

You can use the field "Id" for the Keyword's Id. Please see the Keyword documentation for a list of all supported Keyword fields.

Regards,
Mike, AdWords API Team

Shree

unread,
Jan 22, 2015, 12:22:06 PM1/22/15
to adwor...@googlegroups.com
Hi Mike,

I know that 'Id' field is for Keyword's Id (i.e. CriterionId ) . I am just unable to specify it in serviceSelector below.
Is it possible for you to check the serviceSelector and guide me to specify CriterionId ? This is coded in Python.

Michael Cloonan (AdWords API Team)

unread,
Jan 22, 2015, 12:26:42 PM1/22/15
to adwor...@googlegroups.com
Hello,

You should be able to specify this using:

{
    'field': 'Id',
    'operator': 'EQUALS',
    'values': [the_id_you_want]
}

This is similar to how you've done the other working predicates.

Regards,
Mike, AdWords API Team

Reply all
Reply to author
Forward
0 new messages