MCC and subMCC scripts

17 views
Skip to first unread message

Yoann Berthome

unread,
Feb 26, 2020, 12:23:10 AM2/26/20
to Google Ads Scripts Forum
I got a small issue at the moment not sure how to solve this


Here the things
I have a spreadsheet structured as following
- 1 sheet = 1 CID (CID can be either manager account or customer account id)
---- in each sheet 1 column contain campaign ID, many per sheet

function main() {
var sheets = spreadsheet.getSheets();
var rows = [];
if (sheets.length >= 1) {
for (var i=0;i<sheets.length;i++) {
var sheet=sheets[i];
var sheetName = sheet.getName();
var accountId = sheetName.match(patternCID);
if(accountId && patternCID.test(accountId[0])) {
rows.push(accountId[0]);
}
}
}
startProcess(rows)
}

function startProcess(accountsId) {
try {
var accounts = AdsManagerApp.accounts().withIds(accountsId);
accounts.executeInParallel("processAccount", "allFinished"); //this allow the script works for 60mn total
} catch (e) {
Logger.log(e)
}
}

this is roughly my script to get each account ID

the line that has an issue is

var accounts = AdsManagerApp.accounts().withIds(accountsId);

it's only getting the Customer Accounts, but no Manager accounts are pulled.

Question
- get each client account of a sub-manager account (since the script is on the main MCC)
- can't we get the campaign from a sub-manager account directly?

Some sub-manager is handled by 1 user, therefore I would like the user handle only 1 sheet (the MCC one)







The script is at Top level MCC that will send 1 email with all Account report inside.




Google Ads Scripts Forum Advisor

unread,
Feb 26, 2020, 3:57:59 AM2/26/20
to adwords-scripts+apn2wqczxyxhcjoq...@googlegroups.com, adwords-scripts+apn2wqczxyxhcjoq...@googlegroups.co, adwords...@googlegroups.com

Hi Yoann,

You should be able to query the client accounts belonging to a specific sub manager through the use of the AdsManagerApp.ManagedAccountSelector, wherein you can use the withCondition() and use the ManagedCustomerId column. You can then specify the ID of the sub manager as the condition.

As for your second question, you would need to implement something similar to the above for retrieving the client accounts of a sub manager and then query the campaign information for each of the customer accounts that were returned. For more information on the possible ways to query campaigns, you may refer to this guide.

Let me know if this works on your end.

Thanks,
Peter
Google Ads Scripts Team



ref:_00D1U1174p._5001UXTIGF:ref

Yoann Berthome

unread,
Feb 26, 2020, 9:44:21 PM2/26/20
to Google Ads Scripts Forum
Hello,

Let me clarify some point to be sure we are on the same understanding


Here a mockup structure of the actual things (CID are fake)


123-456-7890 (Main MCC)
     \__234-567-8901 (Sub MCC)
               \__999-888-1111 (Customer Account)

.....\_222-333-4444 (Another Customer Account)


I am running the script on 123-456-7890

I have a spreadsheet with CIDs
and for the example let's take this

[Sheet : 222-333-444][Sheet :  234-567-8901]

each sheet have campaigns ids that I get once I retrieve the accounts (the reason is that I have some MCC not under the main MCC and the script is built to be flexible without using many spreadsheets (1 spreadsheet actually for all my users)

The actual issue is
seems to get only the 222-333-444 but not 234-567-8901

does that mean that the AdsManagerApp is able to get only "Customer Account" and not Manager Account?

I have tested with 2 Customer Account ID, no issue
1 Customer + 1 MCC id and only the customer id is shown.

else I need to rewrite my logic to get from the campaigns the CID of the accounts :)
Reply all
Reply to author
Forward
0 new messages