Retrieve a list of existing shared audiences (particularly CRM)

81 views
Skip to first unread message

stephen.wat...@gmail.com

unread,
Mar 27, 2017, 10:43:24 AM3/27/17
to AdWords API Forum
Hi

I'm a fairly amateurish python user currently creating/updating CRM user based audiences using googleads.

While I've been able to do the above, is it possible to retrieve a list of (all, or just CRM) audiences that exist? names and ids would be more than enough info

I am guesing it involves:
user_list_service = client.GetService('AdwordsUserListService', version='v201702')
but what I would need to do to user_list_service to get the data I require.

I do something similar with facebookads by using:

audiences = my_account.get_custom_audiences(fields=[CustomAudience.Field.name])
audiences = [{"id":d['id'], "name":d['name']} for d in audiences]

Any advice appreciated, cheers

Stephen

Vishal Vinayak (Adwords API Team)

unread,
Mar 27, 2017, 3:43:09 PM3/27/17
to AdWords API Forum
Hi Stephen,

Once you have initialized the service, you can create a service selector to specify the fields that you wish to retrieve via the service (complete list of fields available here). 
  
campaign_service = client.GetService('AdwordsUserListService', version='v201702')

  # Construct selector and get all campaigns.
  offset = 0
  selector = {
      'fields': ['Id', 'Name', 'Status'],
      'paging': {
          'startIndex': str(offset),
          'numberResults': str(PAGE_SIZE)
      }
  }

You can then specify the selector in the AdwordsUserListService.get (as follows) to retrieve the lists in your account:
  
 page = campaign_service.get(selector)

You can use the ListType field in the selector to filter on the CRM_BASED lists only. 
Hope this helps. Please revert if you have additional questions or concerns. 

Regards,
Vishal, AdWords API Team

stephen.wat...@gmail.com

unread,
Mar 31, 2017, 9:17:52 AM3/31/17
to AdWords API Forum
Thanks Vishal, that's perfect!
Reply all
Reply to author
Forward
0 new messages