Map all campaign to their AW full paths: MCC/SubMCC/account/campaign

77 views
Skip to first unread message

EladB

unread,
Aug 24, 2021, 5:45:46 PM8/24/21
to Google Ads Scripts Forum
Hi,

I have an MCC account with sub-MCC accounts.
I want to print all the full AW paths for all disapproved ads.

Using AdsSelector, I will get "Ad" entities. "Ad" cannot return its account-id (let alone its MCC account-id). It can only go as high as its campaign id.

So I need to map all the campaigns to their full AW path.

I thought to map all the campaigns under the base MCC account, but this won't help as the account-selector returns all the children's accounts in a flat mapping so I'm not able to recover the MCC/SubMCC/account path.



Any suggestions?
Thanks

Gat all accounts for MCC - does this return SubMCC accounts? Any way to identify them in contrast to client accounts?





EladB

unread,
Aug 25, 2021, 12:47:37 AM8/25/21
to Google Ads Scripts Forum
To clarify:

I run this code, and then I want to print every disapproved ad's full hierarchy
    var adSelector = AdsApp
      .ads()
      .withCondition("CombinedApprovalStatus IN [DISAPPROVED, SITE_SUSPENDED]")
      .forDateRange("YESTERDAY")
      .get();

I meant: 
MCC ID, Sub MCC ID, Account ID, Campaign ID, Ad group id, ad id

Google Ads Scripts Forum Advisor

unread,
Aug 25, 2021, 3:21:22 AM8/25/21
to adwords...@googlegroups.com
Hi Elad,

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

Unfortunately, the AdsApp.​Ad object won't let you to fully retrieve its hierarchy upto which account it is included or even more so the concerning MCC. Hence, you would have start from the MCC level then retrieve associated entities rather than starting with the ad level. On the other hand, can I interest you in pulling the Ad Performance Report instead? This should let you retrieve the associated ExternalCustomerId and other IDs of each disapproved ad. You can also use the Query Migration Tool to translate AWQL queries into GAQL.

Moreover, the ManagedAccountSelector would only return accounts that are managed by the MCC and will not return sub MCCs as I have mentioned here.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2MiWKy:ref

Elad Ben-David

unread,
Aug 25, 2021, 3:57:37 AM8/25/21
to Google Ads Scripts Forum on behalf of adsscripts
Thanks


1) I will have to run it from the top MCC account. Correct?
2) It will include all ads under this top MCC account (even if there is a middle SubAccount?).
3) How can I then map the full hierarchy path (MCC/SubMCC/CID) from the top MCC?
This would be my way of outputting the MCC/SubMCC/CID/.../AdId for every disapproved ad.

4) If I then want to print other fields of each disapproved ad (e.g. title, description...), I'll have to use AdsSelector?
5) I want to select only the disapproved ads with one of the topic names = ["Enabling dishonest behavior", "Unapproved substances", "Guns, gun parts and related products", "Explosives", "Other Weapons", "Tobacco"];
I don't see "Topic" field in the report. Correct?

image.png

--
-- 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/7Lv89azODE4/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/ektJ2000000000000000000000000000000000000000000000QYDWFG00VqHau6hySpmBFR3q-Keopw%40sfdc.net.

Google Ads Scripts Forum Advisor

unread,
Aug 25, 2021, 10:29:22 PM8/25/21
to adwords...@googlegroups.com
Hi Elad,

Thanks for coming back. Please see my answers below:
  1. I will have to run it from the top MCC account. Correct? 
  1. It will include all ads under this top MCC account (even if there is a middle SubAccount?).
    • In addition to #1, ​you would have to iterate through the account selector then use the select method to retrieve reports each sub/child/single account in your MCC. Same concept applies to this question.
  1. How can I then map the full hierarchy path (MCC/SubMCC/CID) from the top MCC? This would be my way of outputting the MCC/SubMCC/CID/.../AdId for every disapproved ad.
    • ​​​​​​​I believe you would to create a custom function for this one but kindly take note that you won't be able to retrieve sub MCCs as you would intend to.
  1. If I then want to print other fields of each disapproved ad (e.g. title, description...), I'll have to use AdsSelector?
  1. I want to select only the disapproved ads with one of the topic names = ["Enabling dishonest behavior", "Unapproved substances", "Guns, gun parts and related products", "Explosives", "Other Weapons", "Tobacco"]; I don't see "Topic" field in the report. Correct?
Let me know if you have other questions.

Elad Ben-David

unread,
Aug 26, 2021, 7:08:59 PM8/26/21
to Google Ads Scripts Forum on behalf of adsscripts
Thanks


  1. It will include all ads under this top MCC account (even if there is a middle SubAccount?).
    • In addition to #1, you would have to iterate through the account selector then use the select method to retrieve reports each sub/child/single account in your MCC. Same concept applies to this question.
But the selector won't return the subMCC. How do I iterate them as well stating from the top MCC?

  1. I want to select only the disapproved ads with one of the topic names = ["Enabling dishonest behavior", "Unapproved substances", "Guns, gun parts and related products", "Explosives", "Other Weapons", "Tobacco"]; I don't see "Topic" field in the report. Correct?
I wanted to save script running time, so I prefer to filter that in the report query, but I'm looking for "array A has elements which are substring of array B".


Say I have a list of ad ids to remove (same MCC account). Can I bulk remove them somehow?
Instead of one-by-one
  var adsSelector = AdsApp.ads().withIds(adIds).get();
  while(adsSelector.hasNext())
  {
  var ad = adsSelector.next();
    ad.remove();
  }



Say I want to scale this to a very large CID tree (1.6K accounts).
I know using the API library is more suitable, but why? What limitations should I care about? (ads-script in comparison to the API library).
*Timeout after 30 min
*Limited to 50 sub-accounts
*Daily quota of 250 runs.
*What else?

--
-- 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/7Lv89azODE4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Aug 27, 2021, 3:33:33 AM8/27/21
to adwords...@googlegroups.com
Hi Elad,

Teejay here. Allow me to assist you in this. Please see my answers below:


But the selector won't return the subMCC. How do I iterate them as well stating from the top MCC?
  • It is indeed. the ManagedAccountSelector would only return accounts that are managed by the MCC and will not return sub MCCs. As a workaround, you may want to create multiple script for your Top MCC and sub MCC instead
I wanted to save script running time, so I prefer to filter that in the report query, but I'm looking for "array A has elements which are substring of array B". Say I have a list of ad ids to remove (same MCC account). Can I bulk remove them somehow?
  • I'm afraid that is not possible. Since the said method doesn't accept an array values, you need to iterate to your list of ad ids
Say I want to scale this to a very large CID tree (1.6K accounts).
I know using the API library is more suitable, but why? What limitations should I care about? (ads-script in comparison to the API library).
  • The execution limit of the script is maximum of 30 minutes. However, Ads Manager script uses the executeInParallel method to process accounts in parallel, and specify a callback method, then it can execute up to a maximum of 60 minutes before being cancelled. In your use case, it's hard to maintain a very large CID tree (1.6K accounts) using Google Ads Scripts alone as you're likely will reach the execution limits. With this, we would suggest checking Google Ads API instead. 
Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2MiWKy:ref

Elad Ben-David

unread,
Aug 27, 2021, 7:01:21 PM8/27/21
to Google Ads Scripts Forum on behalf of adsscripts
Thanks,

There was one answer missing:

Say I have a list of ad ids to remove (same MCC account). Can I bulk remove them somehow?
Instead of one-by-one


  var adsSelector = AdsApp.ads().withIds(adIds).get();
  while(adsSelector.hasNext())
  {
  var ad = adsSelector.next();
    ad.remove();
  }


--
-- 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/7Lv89azODE4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Aug 31, 2021, 4:55:02 AM8/31/21
to adwords...@googlegroups.com
Hi Elad,

I've answered this on my last response. In this case, I'm afraid it is not possible to bulk remove the entity since the said method doesn't accept an array values. The only approach is to iterate to your list of ad ids just like what you doing right now.
Reply all
Reply to author
Forward
0 new messages