Campaign Negatvie RLSA/User List exclusion with Adwords API

55 views
Skip to first unread message

Alex Fung

unread,
May 18, 2016, 3:51:58 AM5/18/16
to AdWords API Forum
Hi all,

I am working on excluding a user list from a list of campaigns with Adwords API but I can't figure out how.

What I am trying to do is to exclude a user list on the campaign level.
 
I have written a function for that:
API_VERSION = 'v201601'
def Add_Negative_User_List(client,campaignId):
    campaign_criterion = client.GetService('CampaignCriterionService',version=API_VERSION)
    operation = {
        'operator': 'ADD',
        'operand': {
            'campaignId': campaignId,
            'isNegative':True,
            'criterion': {
                'xsi_type': 'CriterionUserList'
                'userListId':'1234567'
            }
        }
    }
    response = campaign_criterion.mutate(operation)


I tried to add the user list as exclusion on the UI and pull the criterion with the API.

this is the response:

(CampaignCriterionPage){
   totalNumEntries = 1
   Page.Type = "CampaignCriterionPage"
   entries[] = 
      (NegativeCampaignCriterion){
         campaignId = 291250879
         isNegative = True
         criterion = 
            (CriterionUserList){
               id = 162191598799
               type = "USER_LIST"
               Criterion.Type = "CriterionUserList"
            }
         CampaignCriterion.Type = "NegativeCampaignCriterion"
      },
 }

Please help me out on this.

Thanks,

Alex

Alex Fung

unread,
May 18, 2016, 4:28:32 AM5/18/16
to AdWords API Forum
I figured out how to do it with API.

python code: 

def Add_Negative_User_List(client,campaignId,userListId):
    campaign_criterion = client.GetService('CampaignCriterionService',version=API_VERSION)
    operation = {
        'operator': 'ADD',
        'operand': {
            'campaignId': campaignId,
            'xsi_type':'NegativeCampaignCriterion',
            'criterion': {
                'xsi_type': 'CriterionUserList',
                'userListId':userListId
            }
        }
    }
    response = campaign_criterion.mutate(operation)
    return response

Joyce Lava

unread,
May 18, 2016, 11:02:10 AM5/18/16
to AdWords API Forum
Hi Alex,

I am glad that you found the fix for the problem above. Please let us know if you need any other help with AdWords API.

Thanks,
Joyce, AdWords API Team
Reply all
Reply to author
Forward
0 new messages