Selecting a single campaign audience by ID

23 views
Skip to first unread message

Haydn Child

unread,
Dec 5, 2019, 6:31:41 AM12/5/19
to Google Ads Scripts Forum
Hi there,

I'm trying to update bids for in-market audiences using a script. I have the list of audience IDs for IMAs and am trying to select a single audience via its ID.  The clearest way to do this seems to be by using audienceSelector.withIds(), however I'm having trouble getting the selector to return any audiences at all. According to the documentation, withIds() takes a 1-dimensional array of IDs, so my code looked like this:

var audiences = campaign.targeting().audiences().withIds([audienceCode]).get();

However I got an error that "Each id must be a 2-element array." (similar to other audiences, but not matching the documentation above). So I've tried the following:

var audiences = entity.targeting().audiences().withIds([[campaign.getId(), audienceCode]]).get();

But that is still returning zero audiences. In all cases I've tried explicitly casting IDs to strings and integers but it hasn't had an effect. The audiences are definitely already applied, both in the interface and by iterating all audiences on the campaign and logging their IDs (iterating through all applied audiences unfortunately doesn't mesh with the workflow I'm trying to achieve here, so isn't a viable alternative option).

Any comments on what could be going wrong would be appreciated!

Google Ads Scripts Forum Advisor

unread,
Dec 5, 2019, 3:58:57 PM12/5/19
to adwords-scripts+apn2wqevqreyimvm...@googlegroups.com, adwords-scripts+apn2wqevqreyimvm...@googlegroups.co, adwords...@googlegroups.com
Hi Haydn,

Thank you for notifying us about the documentation. Can you please provide your CID and script name so I may investigate the second issue?

Thanks,
Matt 
Google Ads Scripts Team

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