Ads script: any easy way to get an ad hierarchy?

354 views
Skip to first unread message

EladB

unread,
Aug 20, 2021, 4:34:26 PM8/20/21
to Google Ads Scripts Forum
Hello,


Say I have an `Ad` object. I want to see its hierarchy (MCC account, sub-MCC account, account, Campaign, AdGroup). Is there any easy way to get it?

Propagating up won't be easy because I don't know it the account has a sub-MCC account ancestor.


Is there any Ad url[1] that shows the hierarchy?

Or any other way?
Thanks

Google Ads Scripts Forum Advisor

unread,
Aug 23, 2021, 3:50:02 AM8/23/21
to adwords...@googlegroups.com
Hi EladB,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

The AdsApp.​Ad object would only let you retrieve its concerning Campaign and Ad Group entities through the getCampaign/getBaseCampaign and getAdGroup/getBaseAdGroup methods. To retrieve the current selected account, you can use the currentAccount method. There is no way to retrieve which account (sub or MCC) a Google Ads entity is included via scripts. Moreover, you may only retrieve sub accounts of an MCC through the AdsManagerApp.​ManagedAccountSelector and not the other way around. The AdsApp.​Account does not offer a get MCC method.

For reference on AdWords AP entity relationships see this link and this link for Google Ads API in which both can be relayed to supported entities in Google Ads scripts.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2MhaDv:ref

EladB

unread,
Aug 24, 2021, 5:13:00 PM8/24/21
to Google Ads Scripts Forum
Thanks, 

I have the top-most MCC account. I want to print all its disapproved ads and their full path.
My only way is to traverse all the campaign one by one, and create a map campaign --> to full path.
And then match each ad from the AdIterator to the full path?


If I do that, and I tree traverse the MCC and Sub-MCC. 
Is there a boolean method that say if an account is an MCC (or subMCC) or just client account?
Is there a ready code for traversing all the accounts?

Google Ads Scripts Forum Advisor

unread,
Aug 25, 2021, 2:54:52 AM8/25/21
to adwords...@googlegroups.com
Hi Elad,

Thanks for coming back. There is no boolean method that would let you tell what level is an account entity. The ManagedAccountSelector would only return accounts that are managed by the MCC and will not return sub MCCs. With this, you can assume all returned accounts by the managed account selector will be single or sub accounts.

Hope this helps. If you need more assistance, let me know.

Elad Ben-David

unread,
Aug 25, 2021, 3:07:38 AM8/25/21
to Google Ads Scripts Forum on behalf of adsscripts
I'm a bit confused: sub account = subMcc?

The ManagedAccountSelector would only return accounts that are managed by the MCC and will not return sub MCCs
With this, you can assume all returned accounts by the managed account selector will be single or sub accounts

Then if I want ads-script to traverse all the accounts including subMCC. How can I do this?

image.png


I want ads-script to print for every disapproved ad its hierarchy (MCC/SubMCC/CampaignId/AdGroupId/AdId).

Since from each Ad I can go up as high as to CampaignId. I thought to do a BFS from Top-MCC through all its children (SubMCC and client accounts) to map each CampaignId --> hierarchy (MCC/SubMCC/account).




--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/ARk_RLYre00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/ojo2R000000000000000000000000000000000000000000000QYDV7B00l2Px3hRJTA-V4rzcD2UL6g%40sfdc.net.

Google Ads Scripts Forum Advisor

unread,
Aug 25, 2021, 6:31:47 AM8/25/21
to adwords...@googlegroups.com
Hi Elad,

Allow me to explain further. What I meant by sub account is single/child accounts and not sub MCC. If you have a MCC account with associated sub MCCs, the ManagedAccountSelector will only return sub/single/child accounts. In addition, the selector I believe would treat sub MCCs as a regular MCC. If you want to use target child accounts of your sub MCCs, then you would have to create the script directly to the sub MCC's account. A more easier approach on retrieving hierarchy for ads would be through reports like I recommended here.

On the other hand, I would appreciate it if we can continue our conversation in a single thread for better tracking purposes on our end.

Elad Ben-David

unread,
Sep 15, 2021, 9:31:53 AM9/15/21
to Google Ads Scripts Forum on behalf of adsscripts
Thanks you very much

"The ManagedAccountSelector will only return sub/single/child accounts. In addition, the selector I believe would treat sub MCCs as a regular MCC. If you want to use target child accounts of your sub MCCs, then you would have to create the script directly to the sub MCC's account."

Then what's the ads-script way to list all sub-MCC and sub-accounts under one Top-MCC?

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/ARk_RLYre00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Sep 16, 2021, 2:27:01 AM9/16/21
to adwords...@googlegroups.com
Hi Elad,

Teejay here. Allow me to assist you in this.

With regard to your concern, I'm afraid that there is no method that will specifically return all sub-MCC and sub-accounts under one Top-MCC. As a workaround, you may utilize the ManagedAccountSelector which will return sub/single/child accounts or setting the ManagerCustomerId in your .with() condition. However, if this workaround does not fit with your use case, I could submit a feature request in your behalf. Could you please provide to use your business terms (or benefit) with regard to the said feature/functionality?

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads Scripts Team
 


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