Help With GTM API Query in Appscript

107 views
Skip to first unread message

R. McCulloch

unread,
May 2, 2023, 2:37:16 PM5/2/23
to Google Apps Script Community
I'm having some issues building out a script that will query the GTM API and list accounts, containers, and workspaces. 

I'm using this documentation for reference. 

I have two questions. 

1) Is the accountPath param the gtm-api account path/url? 

The Oauth2 scope? 

Or the URL account path from the browser? 

Or none of the above. 

2) Suppose I want to submit a GET request to return data about various levels of accounts for a admin user.
So I am looking to return multiple accounts, multiple containers etc. Would I use the .list() method?

How would I structure this for an account? Would it be:

function listAccountInformation(accountPath) {

const account = TagManager.Accounts.list(
        {},
        accountPath
);
return account;
};

Or I could print account or console.log it. I've tried several versions but they're throwing errors.

Thanks!

cwl...@gmail.com

unread,
May 3, 2023, 9:16:02 AM5/3/23
to Google Apps Script Community
I believe it is the url (3rd option you listed).  but just the last two parts:   "accounts/111112"

You can find the account ID by using the API documentation here:
https://developers.google.com/tag-platform/tag-manager/api/v2/reference/accounts/list

Use those APIs to test the functionality once you have your account path and ID.


Reply all
Reply to author
Forward
0 new messages