Partial Container Export in Google Tag Manager

Showcasing the partial container export feature in Google Tag Manager. Partial export lets you choose only a subset of the container to export as a JSON file for importing into other containers.

Exporting a container in Google Tag Manager can have many purposes. From backing up Google Tag Manager versions to creating and distributing repositories of useful container snapshots, the container export is one of the most useful non-tagging-related tools that the GTM user interface offers.

However, one big misgiving in the feature (until now) has been that exporting just a subset of the container version or workspace has been impossible. It’s always the entire container or nothing. If you wanted to remove parts of the export before importing it to another container, you had to do JSON surgery to the contents, removing all the unnecessary or sensitive items before sharing the export file.

Well, Google Tag Manager has now introduced partial export functionality into the container export feature.

Partial export allows you to select only the items you want. It also warns you if you are about to export items without all the references included, offering an easy Add All option to add all the dependencies in one go.

How it works

Click over to Admin in the container, and select Export Container from the list of options under the container.

In the first overlay that appears, you can choose a workspace or a version to export the information from.

Currently, there’s no way to mix-and-match - you can only select items from a single workspace or container version.

In the next overlay (the actual export view), you have the following options at your disposal.

  1. You can select or deselect single items one by one.

  2. You can select or deselect all items in one go.

  3. You can choose to Retain folder structure. If items are in folders, then the respective folders are exported as well, and the links between items and their folders are retained.

  4. You can search through the items for better accessibility.

  5. You can open details for all items (apart from built-in variables).

  6. You can preview what the export JSON would look like with the current selections.

  7. You can export (download) the JSON compiled from your selections.

  8. You can add all the missing dependencies in one go.

  9. You can add missing dependencies item by item.

To operate the tool is dead simple. Just select the item(s) that you want to include in the export, and then click either Preview JSON or Export. The first lets you take a look at the JSON before downloading it, the second downloads it immediately.

Dependency graph

If you try to Preview or Export the JSON, and you’ve selected items that have dependencies (e.g. linked triggers, variable references, tags in a sequence), and you haven’t selected all the dependencies, you’ll see the following warning:

If you choose Export (or Preview if that was your original action), you’ll proceed with the action regardless of the missing references.

If you select Cancel, a new warning about missing references appears in the overlay, and you’ll also see a new column in the table, which lets you sort items by the missing dependency warning.

Note that the dependency graph is only shown for items you tried to export or preview, not for all items in the version or workspace. You need to actually select items and try to preview or export them to trigger the warning and display the missing references.

If you click the warning triangle in the respective column of the table for an item with missing references, a popup will open that shows you what those references are and lets you select all of them in one go.

This is a pretty neat way to make sure that you don’t unintentionally export a subset of the container but end up missing many of the bits and pieces required to make the selected items work.

Summary

As far as quality-of-life improvements go, this is pretty good.

Selective export of a Google Tag Manager container is vital for many workflows out there, as it allows you to do things like keep the staging and live environment in sync, compile a repository of your favorite combinations, and make sure that no sensitive information is accidentally shared when exporting and importing container JSONs.

There are a couple of features that might be useful down the line, such as being able to mix-and-match across container versions and workspaces, and being able to review dependencies before running the export.

But as it stands, I think it’s a useful feature that should make many Google Tag Manager users very happy indeed.