Adding Audience Members - AdWords API - Python

27 views
Skip to first unread message

Carson Whitley

unread,
Jun 8, 2020, 9:59:04 AM6/8/20
to AdWords API and Google Ads API Forum
Looking for code snippet as reference or assistance with respect to "Adding", "Modifying" or, "Deleting" members from an existing Audience. I've found

However, I only wish to populate an existing list. With that, would you just specify the list_id under the user_list dictionary in the example below? So it would just be user_list = 'Insert ListId Here' and further down, user_list_id = result['value']['id']  <-- Pass the actual id in there as well? 

def main(client):
    user_list_service = client.GetService('AdwordsUserListService', 'v201809')

    user_list = {
      'xsi_type': 'CrmBasedUserList',
      'name': 'Customer relationship management list #%d' % uuid.uuid4(),
      'description': 'A list of customers that originated from email addresses',
      # CRM-based user lists can use a membershipLifeSpan of 10000 to indicate
      # unlimited; otherwise normal values apply.
      'membershipLifeSpan': 30,
      'uploadKeyType': 'CONTACT_INFO'
    }

    # Create an operation to add the user list.
    operations = [{
      'operator': 'ADD',
      'operand': user_list
    }]

    result = user_list_service.mutate(operations)
    user_list_id = result['value'][0]['id']

If you're uploading via the API, is hashing information the only option? In manual uploads, you do not have to.

Google Ads API Forum Advisor Prod

unread,
Jun 8, 2020, 2:15:05 PM6/8/20
to cwhi...@budgetdumpster.com, adwor...@googlegroups.com

Hi Carson,

This line of code is where you get the user_list_id created in this example. However, if you are using an existing user_list_id you don’t need to create it and you wouldn’t want to pass in the user_list_id into the id field in this line of code. You actually would need to pass in the existing user_list_id in this line instead. As for the other question, hashing would be a good way to protect customer’s privacy so the customer data must be normalized and hashed. It is the same for the Google Ads UI that these sensitive information would be hashed but we don’t directly see the change as it’s something working underneath the hood.

Thanks and regards,
Xiaoming, Google Ads API Team

 

 


 

ref:_00D1U1174p._5004Q20X3yJ:ref
Reply all
Reply to author
Forward
0 new messages