A Simple GTM Rename Helper

Renaming GTM at Scale & without APIs*

In the busy world of data & technology, it's easy to get caught up in all the exciting business driven data  initiatives. However from time to time it's good to jump back into the fundamentals.

A soft spot for me is having great naming conventions applied in your Tag Management platforms, it's not fancy and more challenging to quantify a ROI, but it's important for long term management and quality control. 

Recently we were tasked to clean up a few GTM Containers and while in the past we had developed versions of Apps Script to assist, I thought why not loosely integrate a LLM given its like a pretty natural for renaming purposes. Applying conventions consistently across a large number of configurations is often quite tedious and time consuming, however I  wanted to keep the human touch - so  an automation that would get us 80-90% of the way.

We didn’t want to just rename, we wanted a score card to go with it. This post explores that journey and provides the link to a standalone Google Sheet asset you can make your own.

Why Rename

Naming conventions are an essential component of long term management of a Google Tag Manager container. Inconsistent naming and a  lack of clarity can often lead to redundant configurations, mistakes, poor data collection and increase the effort to add/edit configurations. 

Consistent naming aids when working across multiple Google Tag Managers, ensuring activities/signals are approached holistically rather than ad hoc.

Over time GTM containers will likely become bloated and inconsistent, a product of being worked on by many different users and organizations. Given the reactive nature of tagging, getting it live is a priority over worrying too much about what things are called or bother with re-using existing configurations and this will often result in a much needed clean up.

Below is the criteria we use to score the naming conventions to aid in improving the current taxonomy.

A Semi-Automated Manual Solution

We wanted to have a bit of fun, experiment with AI Chat and put together a solution that keeps things simple and accessible, avoiding APIs. The build is contained within Google Sheets and intended to be used in combination with ChatGPT, but might work with other AI Chat as well.

The suggestions respect practical rules like Title Case for human labels, snake_case for GA4 event keys, and utility prefixes for Custom HTML when the service isn’t identifiable.

General conventions applied:

  • Tags: [Platform] - [Type] - [Event/Detail] - [Extra] (e.g. GA4 - menu_click - main menu)

  • Triggers: [Type or Abbreviation] - [Context] - [Detail] (e.g., CE - form_submit)

  • Variables: [Type Abbreviated] - [Key/ID] - [Context] (e.g., FPC - _ga)

What does it do:

  • Imports a GTM container JSON export into a structured Google Sheet.

  • Creates a prompt based on the Imported JSON using pre-defined rules, examples and other instructions included in the Apps Script

  • The prompt scores naming consistency across five dimensions (structure, style, platform clarity, semantics, hygiene).

  • The prompt can auto-suggest cleaned names using a canonical mapping 

    • (e.g., gaawe -> GA4 - Event, gclidw -> Google - Conversion Linker).

  • The prompt can export a ready-to-review CSV of suggested names (tags, triggers, variables).

  • Import the CSV back into Google Sheets for a side-by-side comparison.

Architecture

  1. Google Sheet

    • Configuration-Prompt - GTM JSON Export table for the prompt

    • Suggested Names - Can drop in result from the Prompt for side-by-side review

    • Scoring Consistency - Optional template to paste Score Card results

    • Menu: Digital Immersion  - Paste JSON, Create Prompt, Clear helpers

  2. Apps Script (600ish lines)

    • Parses GTM export (tags/triggers/variables) into Configuration-Prompt Sheet, maintaining lookup columns.

    • Applies a mapping dictionary to align platforms & types, examples and other useful context.

    • Builds a JSON payload prompt a model can score and annotate

  3. Prompt result

    • Returns a Score table + Observations

    • (Optional) Generate a CSV of cleaned names for bulk review and import

Workflow

  1. Goto GTM 

    1. https://tagmanager.google.com/#/home

    2. Locate your container -> Accounts -> Container 

    3. Export your container -> Admin -> Export Container -> Choose Workspace -> Preview JSON

    4. Select All & Copy JSON

  1. Paste the GTM export

    1. Visit the helper sheet 

    2. Make a copy

    3. Open your sheet

    4. Goto Menu -> Digital Immersion -> 1. Paste GTM JSON Export

    5. Paste the Preview JSON in the popup window

    6. Wait for it to process

      1. Please note GTM configurations can be complex, it's possible if your container is extensive or has a lot of custom code/legacy configurations the json parse may encounter issues or take a while.

  1. Create the audit prompt

    1. Goto Menu -> Digital Immersion ->  2. Create Prompt

    2. Copy the generated JSON and paste

    3. Goto your AI Chat e.g. ChatGPT

    4. Paste in the prompt, cross your fingers and hope the result is not hallucinated

  1. Review the score & observations

    1. You’ll get a markdown table and concise recommendations.

    2. (Optional) Copy the recommendations into “Scoring Consistency” in your Google Sheet

  2. Export suggested names

    1. Ask for the CSV; preview in-chat, then download.

    2. Import the table into your Google Sheet and drop correctly in the provided columns in Suggested Names

Example output

The goal isn’t perfection, it’s to improve the clarity & consistency. Small deviations will be tolerated, however  structural inconsistencies are not.

Score Card

Suggestions


Conclusion

Key Takeaways

  • Naming is tedious but important.

  • If a manual task is going to take hours, there is likely some sort of automation you could create/use to take some of the pain away.

  • Sheets + App Script is powerful and can accomplish POC’s relatively quickly.

Where it could go

While this sheet will rename the configurations for review, you could consider making updates to push the changes back into GTM automatically, saving effort on the actual renaming. This could be achieved by either re-creating/updating  the  JSON export  for reimport or  leveraging the Google Tag Manager API library in Google Sheets  (watch out for the 25 requests per 100 seconds if you do) . 

The GTM API is pretty flexible once you wrap your head about some of the more complex JSON structures, however the name property  is one that is fairly easy to update.  The inbuilt OAuth in Google Sheets makes accessing Google's APIs a breeze and I often think this is a fairly underrated and underutilized feature of working with sheets.

Want to try it?

Visit the sheet , make your own  copy and follow the workflow. If you run into any issues or just want to chat about anything data, digital, technology, reach out to  me on linkedIn.

Once you make a copy the email/account you used will be the owner of the sheet and script. When you go to authorize you will likely encounter some permission warnings that you will need to navigate and accept.

Please keep in mind we put this together over an afternoon and a cup of tea, so your experience and results  may vary.

Next
Next

The Death of the CDP?