Importing and Exporting Containers in Google Tag Manager (GTM) allows you to move tags, triggers, variables, and other configurations between different GTM accounts or containers. This is helpful when migrating setups, sharing configurations between teams, or backing up GTM containers. Below is a step-by-step guide on how to import and export GTM containers.
Exporting a Container in GTM
Exporting a container in GTM allows you to download the container’s configurations (tags, triggers, variables, etc.) in a file format that can later be imported into another GTM account or container.
Steps to Export a GTM Container:
- Log in to Google Tag Manager:
- Go to the Google Tag Manager website and log in with your Google account.
- Select the Container:
- From the GTM dashboard, select the container you want to export.
- Go to Admin Panel:
- In the left sidebar, click on Admin. This will take you to the Admin interface for your selected container.
- Export Container:
- Under the Container column (the second column in the Admin section), click on Export Container.
- A dialog box will appear asking you to choose a version of the container to export.
- Select the version you want to export (usually, you will select the latest version, but you can export any published or draft version).
- Click Export.
- Download the Container File:
- After selecting the version, GTM will generate a
.json
file containing the configuration of the container. This file will be automatically downloaded to your device. - This
.json
file can now be used for importing into another GTM container.
- After selecting the version, GTM will generate a
Importing a Container into GTM
Once you have exported the .json
file from one container, you can import it into another GTM container or even into a new GTM account.
Steps to Import a GTM Container:
- Log in to Google Tag Manager:
- Go to Google Tag Manager and log in with your Google account.
- Select or Create a New Container:
- From the GTM dashboard, choose the account and container where you want to import the configuration.
- If you are importing into a new container, click Create Container, enter the necessary details, and create a new container.
- Go to Admin Panel:
- In the left sidebar, click on Admin.
- Import Container:
- Under the Container column, click on Import Container.
- A dialog will appear asking you to upload the
.json
file you exported previously.
- Choose the Import File:
- Click Choose File and select the
.json
file you want to import.
- Click Choose File and select the
- Choose Import Options:
- You will be presented with a few import options:
- Create new tags, triggers, and variables: Select this option if you want to import everything from the container as new elements.
- Overwrite the current container configuration: This option will replace your current container configuration with the imported container’s configuration. Be cautious with this option, as it will override any existing configurations in the container.
- Merge with the current container: This is the most commonly used option, where the imported configuration will be added without replacing the existing one. You’ll see the tags, triggers, and variables that are in the imported container and will have the option to merge or exclude them.
- You will be presented with a few import options:
- Review Changes:
- GTM will show you a summary of the tags, triggers, and variables being imported. Review these to ensure that the import will align with your needs.
- Complete the Import:
- Once you’re ready, click Confirm to complete the import process.
- Publish the Container:
- After importing, you will need to publish the container to apply the changes. Click on Submit in the top-right corner and provide a version name and description to help identify the changes made.
Handling Conflicts During Import
When importing a container, GTM checks for any conflicts between existing and imported elements (tags, triggers, variables, etc.). You’ll be notified if the import contains elements that conflict with existing configurations in the target container.
You have several options to manage these conflicts:
- Overwrite: Replaces the existing element with the new one from the import.
- Merge: Combines the new element with the existing one, if possible, without causing conflicts.
- Exclude: Skips the element during the import.
Best Practices for Importing and Exporting Containers
- Test in a Staging Environment: Before importing a container into a live environment, it’s a good idea to test it in a staging or testing container. This helps prevent any issues from affecting live tags or data.
- Backup Existing Containers: Always export and download a backup of your current GTM container before importing new configurations. This ensures you can revert to the previous state if necessary.
- Version Control: Keep track of the version of containers you are importing and exporting. Name the versions logically (e.g., “Product Page Tag Setup” or “Version 1.2.3”) to easily reference and understand what changes have been made.
- Review Tags, Triggers, and Variables: When importing, carefully review the tags, triggers, and variables that will be added or replaced. Ensure that the configurations are accurate and won’t disrupt your existing tracking setup.
- Import Incrementally: If you’re importing from a large configuration, consider importing tags, triggers, and variables incrementally. This way, you can monitor the effect of each import and avoid overwhelming the container with too many changes at once.
Troubleshooting Common Import/Export Issues
- Error during Import: If you receive an error during the import process, check that the
.json
file you are importing is valid and correctly formatted. If the issue persists, re-export the container and try again. - Conflict Errors: If GTM detects conflicts between the imported container and the existing container (for example, if tags or triggers with the same name already exist), you may need to manually resolve them. Review the details in the import summary and decide whether to overwrite, merge, or exclude conflicting elements.
- Changes Not Applied: If the changes don’t appear after the import, make sure you publish the container. Changes are not live until the container is published.
Conclusion
Importing and exporting containers in Google Tag Manager is an essential feature for managing and migrating tag configurations. By following the steps above, you can ensure that your GTM containers are backed up, shared, and migrated efficiently between different accounts and containers. Always take extra caution with merge and overwrite options to avoid unintentional disruptions in your tracking setup. With the right approach, GTM’s import/export feature can save time and effort, especially when working with multiple accounts or teams.