How to query across accounts with this account hierarchy.

Nick B 1 Reputation point
2024-05-13T18:31:58.4366667+00:00

Hello. I am trying to write a script that will allow my company to record stats across the hundreds of Microsoft Ads accounts that we manage on our clients' behalf.

We have an unusual account structure/hierarchy that seems to render the existing single-account and multi-account access documentation unhelpful. No matter what I try, I cannot select any account other than the direct child account that is associated with our organization. Below is but one of the scripts I have written to try to access the broader account hierarchy. Finally, I have attached a screenshot of the account hierarchy as it appears in the Accounts Summary of the parent manager account.

Any help in the right direction will be very useful. Thanks so much!

function main() {

Logger.log("Script started");

// Fetch the accounts linked to the current manager account

var accounts = AccountsApp.accounts().get();

while (accounts.hasNext()) {

var account = accounts.next();

Logger.log("Found Account: " + account.getName() + " (" + account.getAccountId() + ")");

// Process further based on your requirements

}

}

main();

Screenshot 2024-05-13 084541

Microsoft Advertising API
Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
391 questions
0 comments No comments
{count} votes