Build a GTM container report with Apps script
1. Create a new Google Sheet, enter the Script Editor via the Tools menu, and name the project.
Don’t close the browser tab with the Google Sheet, or the Script Editor will close as well.
2. Click the + icon by Services in the editor navigation, select Tag Manager API, and click Add.
Add Tag Manager API to the project
3. Copy the Apps script source code and replace everything in the Script Editor Code.gs file with the source code.
Copy the source code and replace everything in the Script Editor Code.gs file.
4. Select onOpen from the list of script functions, then click Run to execute the extension code and add it to the Sheets Add-ons menu.
Select onOpen and then click Run
5. Authorize the Google Sheet to access your Google Tag Manager container.
Click through the prompts to authorize the Sheet’s access to your GTM container. If you see a warning about an unverified app, expand the error message and click the link that says Proceed.
6. Go back to the browser tab with the Google Sheet and locate your add-on in the Add-ons menu once the script has run successfully.
The name of the Add-on will be whatever you named the project.
7. Click the Build Hierarchy option in the Add-ons menu to automatically create a new sheet named GTM Hierarchy populated with the Google Tag Manager accounts and containers you have access to.
If you run into a quota or query limit error, log in with a Google Account that has access to a smaller number of containers.