How to use container export and import functionality in Google Tag Manager

Author:

Google Tag Manager (GTM) is a powerful tool that enables marketers and developers to manage and deploy marketing tags (like analytics tracking codes, remarketing tags, and more) without requiring code changes on the website. One key feature that makes GTM versatile is the ability to export and import containers. This functionality allows users to transfer containers between different GTM accounts, back up configurations, and migrate setups across environments (like from staging to production) seamlessly. This article discusses how to use the container export and import features in Google Tag Manager.

Understanding Containers in Google Tag Manager

A “container” in GTM holds all your tags, triggers, and variables for a specific website or app. Each GTM account can have multiple containers, and each container can be used for different projects or environments. For example, you could have separate containers for a staging site and a live website.

The container export/import functionality allows you to share or replicate configurations across different GTM accounts, making it an essential feature for efficient management of GTM implementations.

Why Export and Import Containers?

There are several reasons you might want to use the export and import functionality in Google Tag Manager:

  1. Backup: Exporting a container is a great way to create backups of your GTM setup.
  2. Migration: When moving a GTM setup from one environment to another, for example from development to production, exporting and importing containers makes the process quick and error-free.
  3. Collaboration: Exporting containers allows sharing configurations with teammates or external collaborators.
  4. Reusability: If you have a complex setup, exporting and importing containers allows you to reuse the same tags, triggers, and variables in multiple GTM accounts.

Step-by-Step Guide: Exporting a GTM Container

Here is how to export a container from your Google Tag Manager account:

  1. Sign in to Google Tag Manager:
  2. Select the Container:
    • From the GTM dashboard, select the container you want to export. This can be a container for your website, mobile app, or another project.
  3. Access Admin Panel:
    • Once you’re inside the desired container, click on the “Admin” option in the navigation bar at the top of the screen. This will take you to the administrative section of your GTM container.
  4. Export Container:
    • In the Admin section, look for the Container column and click on Export Container.
    • You will be prompted to choose the version of the container you wish to export. You can either export the latest version or select a previous version, depending on your need.
  5. Download the Exported File:
    • After selecting the container version, click Download to save the container as a .json file. This file contains all your tags, triggers, and variables in the container.
    • The exported file can now be shared with others, stored for backup, or imported into another GTM account.

Step-by-Step Guide: Importing a GTM Container

Now that you have an exported container file, you can import it into another GTM account or a different container. Here’s how:

  1. Sign in to Google Tag Manager:
  2. Select the Destination Account and Container:
    • Navigate to the GTM account where you want to import the container. If you’re working in a different account or container, select the appropriate one.
  3. Access Admin Panel:
    • Go to the “Admin” section by clicking on the “Admin” button in the navigation bar.
  4. Import Container:
    • In the Admin section, under the Container column, click on Import Container.
    • You’ll be prompted to upload the .json file that you exported earlier. Select the file from your computer.
  5. Choose Import Options:
    • You will have several import options:
      • Overwrite: This option will replace the existing tags, triggers, and variables in the destination container with those from the exported container. It’s useful when you want to completely replicate the setup from the source container.
      • Merge: This option merges the exported container’s settings with the existing container settings. Tags, triggers, and variables that are not present in the destination container will be added, while existing configurations remain unchanged.
      • Create New Versions: You can opt to create a new version of the container rather than overwriting or merging the configurations. This allows you to keep the original configuration intact and track changes.
  6. Review and Confirm:
    • After selecting your import preferences, review the changes that will be made to your destination container.
    • Click Confirm to proceed with the import.
  7. Publish the Changes:
    • After importing the container, you can publish the changes to make the new setup live. GTM will create a new version of the container, which you can test before publishing.

Considerations When Exporting and Importing Containers

While exporting and importing containers is a powerful tool, it’s important to keep some considerations in mind to avoid issues:

  1. Account-Level Configuration: GTM containers don’t carry over account-level settings. If you export a container from one GTM account and import it into another, account-specific settings (like user permissions and integrations) will not be transferred. Ensure that the destination account has the required settings before importing.
  2. Version Control: Each time you import a container, a new version is created in the destination account. Keep track of these versions, especially when using the Overwrite or Merge options, to avoid unintentionally overwriting important configurations.
  3. Environment Considerations: If you’re importing containers between different environments (such as from staging to production), make sure that any environment-specific settings (like tracking IDs, data layer variables, or triggers) are properly configured to avoid misfires or incorrect tracking.
  4. Testing Before Publishing: It’s a good practice to test the imported container setup in the destination environment using GTM’s Preview mode before publishing any changes. This will help ensure that all tags fire correctly and triggers are working as expected.
  5. Data Loss Risk: While merging containers, be cautious about inadvertently losing custom variables, triggers, or tags that are exclusive to the destination container. Always back up both the source and destination containers before making any changes.

Best Practices for Using Export and Import in Google Tag Manager

To get the most out of GTM’s export and import functionality, here are some best practices:

  1. Use Version Control: Always export a container before making major changes. This will allow you to roll back if something goes wrong or if you need to revert to an earlier setup.
  2. Set Up Staging and Production Containers: Create separate containers for staging and production environments. This allows for better testing and minimizes the risk of errors on your live site.
  3. Document Your Setup: Keep track of what each container contains. Especially when working in large teams, having a clear documentation structure helps everyone understand the container’s purpose and the settings it contains.
  4. Collaborate Effectively: Export and import containers as a way to collaborate with team members. You can share your GTM configuration with others, who can import it and continue working on it without starting from scratch.
  5. Test Thoroughly: Always test your setup in GTM’s preview mode before publishing the imported configurations. This helps ensure the setup works in the new environment.

Conclusion

Exporting and importing containers in Google Tag Manager provides an easy and efficient way to manage and share tag configurations across different environments and GTM accounts. Whether you’re backing up your setup, migrating between stages, or collaborating with team members, this functionality saves time and helps prevent errors. By following best practices and keeping a good version control process, you can effectively leverage GTM’s export and import features to maintain a well-structured and optimized tag management setup.