Ids and mutating ads

147 views
Skip to first unread message

GregT

unread,
Jun 12, 2018, 12:22:00 AM6/12/18
to AdWords API and Google Ads API Forum
Hi,

I saw that in the recent v201806 release of the API, there is now the ability to mutate ads. This would make some things simpler for us where we're currently doing removal and adds to accomplish the same thing, so it'd be nice to use it. However, I'm a little hesitant, because something seems wrong about it. According to https://developers.google.com/adwords/api/docs/guides/ad-features#mutating_ads_for_v201806_and_later, you can mutate the Ad by using the new AdService, setting the id field of the Ad, setting whatever fields you want to change, and sending it with the SET operator. The part that worries me is that ad ids are not globally unique, even within a single account, but are unique only within an ad group (https://developers.google.com/adwords/api/docs/guides/objects-methods). So, it seems unsafe and error prone to be able to modify an ad by specifying just its id, as you could have more than one ad in your account with that id, leading to modifying the wrong ad or an error (if the AdWords API is checking for this and returning a SOAP fault for it)? Or am I missing something?

Thanks in advance,
Greg

Anash P. Oommen (AdWords API Team)

unread,
Jun 12, 2018, 12:32:01 PM6/12/18
to AdWords API and Google Ads API Forum
Hi Greg,

We need to update the Unique IDs documentation a bit, now that AdService is available. The more detailed version is like this:

- AdId represents a globally unique creative ID. This means that you can edit an Ad using AdService using creativeId without any concern of ID collision.

- AdGroupAd is a link that associates an Ad to an AdGroup. But we don't expose an AdGroupAdId. You could use the pair (adgroupid, adid) as a proxy ID for AdGroupAd. Hence our warning that when querying using AdGroupAdService.get, you should not consider adId to be a unique Id, you should rather use the pair (adgroupid, adid) as a unique pair.

So, you are fine if you follow these guidelines:

1. When using AdGroupAdService.get, use (adGroupid, adId) as a unique ID for querying purposes.
2. When using AdService.mutate, use adId as a unique ID for updating the ad.

Hope this helps?

Cheers
Anash P. Oommen,
AdWords API Advisor.

GregT

unread,
Jun 12, 2018, 1:01:24 PM6/12/18
to AdWords API and Google Ads API Forum
Hi Anash.

Thanks for the quick reply and clearing that up. It makes sense. 

I will say that I've been using the API for years, and I've always taken that page on id uniqueness to mean that we had to be careful within our code and database to deal with the possibility that an ad id might be reused across ad groups even within a single account -- as that's the way the documentation reads to me. Maybe this is what you're saying you guys are planning on doing, but it seems like a better way to do the documentation is to have https://developers.google.com/adwords/api/docs/guides/objects-methods really list what it appears it's listing (what scope various ids are unique within), and document in the individual SOAP services whether or not you need to include something like AdGroupId in the get/set calls even though something like the ad id might be globally unique itself.

So does this also mean that CriterionId (e.g. keyword and product partition ids) are also globally unique, even though the documentation says that the (AdGroupId, CriterionId) pair is what's globally unique (like it does with the [AdGroupId, AdId] pair)? 

Thanks,
Greg

Anash P. Oommen (AdWords API Team)

unread,
Jun 12, 2018, 1:56:38 PM6/12/18
to AdWords API and Google Ads API Forum
Hi Greg,

Yes, the way you read the documentation is correct. Ad Ids may be reused across ad groups. As I mentioned in my previous post, AdGroupAd is not the same thing as Ad. Ad is the actual underlying entity, and AdGroupAd is a link that associates an AdGroup and an Ad. A typical example where you might see AdId getting reused across AdGroups is when using is shared Ads. 

Cheers
Anash

GregT

unread,
Jun 12, 2018, 2:53:15 PM6/12/18
to AdWords API and Google Ads API Forum
Okay - sorry for the confusion, Anash. I think my confusion came from how we would need an ad group id to identify AdGroupAds uniquely if ad ids are unique, and I forgot about shared ads because AdWords got rid of them 2 or 3 years ago. Are there cases where an ad id can be shared across ad groups nowadays?

And sorry, I realized the criterion id uniqueness question was silly right after posting it, as I've definitely seen reused product partition and keyword ids across ad groups many times.

Thanks again,
Greg

Anash P. Oommen (AdWords API Team)

unread,
Jun 13, 2018, 1:38:26 PM6/13/18
to AdWords API and Google Ads API Forum
Hi Greg,

One instance I can think of is when you clone campaigns in the UI by copy-paste. Ad IDs are reused AFAIK in that case.

Cheers
Anash P. Oommen,
AdWords API Advisor.

GregT

unread,
Jun 13, 2018, 3:49:46 PM6/13/18
to AdWords API and Google Ads API Forum
Okay - thanks for the information, Anash.
Reply all
Reply to author
Forward
0 new messages