'How to export google tag manager tags and triggers into Excel or Google sheet file?

I have to do an audit for different Google tag manager accounts and I would like to export from their respective containers the tags and triggers into an excel or a google sheet file Do you know if this is possible?

Please can someone help me with this?



Solution 1:[1]

You have to use Google Tag Manager API: https://developers.google.com/tag-manager/api/v2

You can manage tags and triggers. You can use Apps Script and relative Tag Manager Service to get info you want directly from a Spreadsheet: https://developers.google.com/apps-script/advanced/tag-manager

Solution 2:[2]

I needed to do something similar today, so here's a script I quickly up with to extract the filters and their conditions to a CSV.

Simply run it in your console:

document.querySelectorAll('tr[gtm-table-row]').forEach(n => {
    const triggerName = n.querySelector('td:nth-child(2)').textContent.trim();
    const eventType = n.querySelector('td:nth-child(3)').textContent.trim();
    const triggerConditions = '"' + Array.from(n.querySelectorAll('td:nth-child(4) .gtm-predicate-summary-row')).map(conditionElement => conditionElement.textContent.trim()).join(',') + '"';

    console.log(`"${triggerName}", "${eventType}", "${triggerConditions}");
});

It's far from complete. I only tested it for the Triggers view, there's no pagination support, it's error-prone if you have double-quotes in your filter conditions, etc...

But that should help people who end up on this post to get started.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michele Pisani
Solution 2 haylem