How to Import and Export Containers in Google Tag Manager

Author:

Google Tag Manager (GTM) allows you to manage and deploy marketing tags (snippets of code) on your website or mobile app without modifying the codebase. One powerful feature of GTM is the ability to import and export containers. This is particularly useful for replicating tag setups across multiple sites, backing up configurations, or sharing configurations with others.

Exporting a Container from Google Tag Manager

 1. Sign in to Google Tag Manager

  1. Navigate to Google Tag Manager:
  2. Select Your Container:
    • Once logged in, select the GTM container you want to export from the list of available containers.

 2. Access Admin Settings

  1. Go to Admin:
    • In the left-hand menu, click on Admin.
  2. Export Container:
    • Under the Container column, click on Export Container.

 3. Export Container

  1. Select Container Version:
    • Choose the container version you wish to export. You can select the latest workspace or any previously published version.
  2. Export:
    • Click Export to start the export process.
  3. Download JSON File:
    • GTM will generate a JSON file containing your container configuration. Download this file to your computer. This file includes all your tags, triggers, variables, and settings.

Importing a Container into Google Tag Manager

 1. Sign in to Google Tag Manager

  1. Navigate to Google Tag Manager:
  2. Select or Create a Container:
    • Choose the container you want to import into from the list of available containers. Alternatively, you can create a new container if you are setting up a new project.

 2. Access Admin Settings

  1. Go to Admin:
    • In the left-hand menu, click on Admin.
  2. Import Container:
    • Under the Container column, click on Import Container.

 3. Import Container

  1. Choose Container File:
    • Click Choose container file and select the JSON file you exported earlier.
  2. Select Workspace:
    • Choose the workspace where you want to import the container. You can import into an existing workspace or create a new one.
  3. Choose Import Options:
    • Overwrite: This option will replace all existing tags, triggers, and variables in the selected workspace with those from the imported container.
    • Merge: This option will combine the imported container with the existing one. If there are conflicts (e.g., tags, triggers, or variables with the same name), you will need to choose how to resolve them (e.g., overwrite, rename, or leave unchanged).
  4. Review Changes:
    • After selecting your import options, GTM will show a summary of the changes that will be made. Review this summary carefully to ensure it meets your expectations.
  5. Confirm Import:
    • Click Confirm to complete the import process.

 4. Adjust Configurations

  1. Update Site-Specific Settings:
    • After importing the container, you may need to update certain site-specific settings such as Google Analytics tracking ID, URLs, and any other parameters that are unique to the new site.
  2. Check Variables:
    • Ensure that all variables, especially those that are site-specific (e.g., Data Layer variables, custom JavaScript variables), are correctly configured.
  3. Adjust Triggers and Tags:
    • Modify any triggers or tags that might have dependencies on specific URLs, CSS selectors, or other site-specific elements.

 5. Test Your Setup

  1. Enter Preview Mode:
    • In the GTM workspace, click Preview to enter preview mode. This allows you to test your tags in a live environment without actually deploying them.
  2. Test Tags and Triggers:
    • Navigate through your website and perform actions that should trigger your tags. Verify that all tags fire correctly and that the expected data is being collected.
  3. Use Debug Pane:
    • The GTM debug pane will show you which tags fired, which variables were set, and the values of those variables. Use this information to verify that everything is working as intended.

 6. Publish Your Changes

  1. Submit Changes:
    • Once you are satisfied with the setup and have tested it thoroughly, click Submit in the GTM workspace.
  2. Publish Container:
    • Add a version name and description to document what changes were made.
    • Click Publish to make your changes live.

Tips for Importing and Exporting Containers

  • Back Up Existing Configurations:
    • Before importing a new container, export the existing container as a backup. This ensures you can revert back if something goes wrong.
  • Maintain Naming Conventions:
    • Use consistent naming conventions for tags, triggers, and variables to avoid conflicts and make it easier to manage your configurations.
  • Document Changes:
    • Keep documentation of what each container version includes, especially if you are sharing it with others or using it across multiple projects.
  • Version Control:
    • Use GTM’s built-in version control to track changes. This helps maintain a history of modifications and makes it easier to revert to previous versions if needed.
  • Testing:
    • Thoroughly test your configurations in GTM’s preview mode before publishing them. This helps catch any issues before they go live.

Example Use Case: Setting Up a New Site

Let’s walk through an example where you want to set up GTM for a new site using an existing configuration.

  1. Export Container from Existing Site:
    • Follow the steps to export the container from your existing site that has a well-configured setup.
  2. Create a New Container for the New Site:
    • In GTM, create a new container for the new site.
  3. Import the Container:
    • Follow the steps to import the exported container into the new container.
  4. Adjust Configurations:
    • Update any site-specific settings (e.g., Google Analytics tracking ID, URLs) in the new container to match the new site.
  5. Test and Publish:
    • Test the configurations using GTM’s preview mode.
    • Once confirmed, publish the container.

By following these detailed steps, you can efficiently manage your GTM setups across different sites and projects, ensuring consistent tracking and tag management. This allows you to replicate successful configurations, streamline the setup process for new sites, and maintain a high level of control over your tracking implementations.