Notification

G Suite is now Google Workspace: everything your business needs to get work done.

Environments

Configure how Tag Manager works between development and production server environments.

The environments feature in Google Tag Manager is ideal for organizations that want to preview their container changes in a test environment before those changes are published. This feature is useful for organizations that use multi-tiered environments in their development workflow (e.g. 'development', 'staging', and 'production'.)

Setup overview

There are three high-level steps to set up environments with Tag Manager:

  1. Define your environments.
  2. Install the relevant container snippet for each environment on their respective sites.
  3. Publish the container to the desired environment.

You can set up as many environments as is required for your workflow, and you can publish any version of your container to any environment you have defined.

Tip: An alternative way to use environments is to use an environment's preview function. Share the preview link for whatever version of the environment you'd like to preview. With this method, you don't have to install and deploy a special environment code snippet.

Define environments

The first step is to define your environments. Decide what each environment will be called, and what the purpose of each environment will be. Often this is has already been established by your development team or organization. Here is a commonly-used convention:

  • Dev – This server is what you and your team use for day-to-day website development.
  • QA – A server that is used for quality assurance testing. Policy might be set such that all changes must pass through this server and be tested before those changes are moved to the live environment.
  • Live – The server hosting the live version of your website; the version that is visible to your users.
Note: Every container is set up with a "Live" environment by default, which always points to the container version that is currently published. You don't need to define the Live environment.

Once you have your environments defined, you can configure them in Tag Manager:

  1. Click Admin.
  2. In the Container menu, click Environments.
  3. Click New. The Create Environment box appears.
  4. Enter a Name for your environment.
  5. Optional: Enter a Description and Destination URL.
  6. Optional: Check Enable Debugging by Default if you need the environment to always use preview mode.
  7. Click Create.
  8. You will be prompted to publish your environment. Click Publish Now to publish the environment. You will have the option to change the version of the container published to the environment with the Version menu. Your new environment should now appear in the Custom Environments list.
Note: When you publish a custom environment, you will not send those changes to the live version of your container. Those changes are only viewable on a server that has the correct environment's container snippets installed, or in a browser that has used the shared preview link.

Install container snippets

The next step is to install your container snippets. This process is similar to installing a standard Tag Manager container snippet, except that you have to do this on every server that has a corresponding environment defined in Tag Manager. This step may require assistance from a developer or systems administrator to complete.

  1. In the Custom Environments listing, find the entry for the environment you would like to install.
  2. Click the Actions menu for that entry.
  3. Select Get Snippet.
  4. Copy the resulting code snippet and install it so that it will appear in the code of the target environment.
  5. Save and publish the website's code changes.

When you have custom environments defined, the Publish dialog will add a menu so that you can define to which server the changes will be published.

  1. Click Publish in the upper right corner of Tag Manager.
  2. Choose a selection from the Environment menu for where you want to publish your changes.
  3. Click Publish.

The Environments feature is designed for use with non-production environments. To ensure the best performance, you should install the standard Tag Manager container snippet on live/production websites.

Set versions

Once your custom environment has been defined, you can set that environment to any version of your container:

  1. In the Custom Environments list, find the entry for the environment you would like to install.
  2. Click the Actions menu.
  3. Select Publish To....
  4. Use the Version menu to select the desired container version for this environment.
  5. Click Publish Now.

Share previews

You can share previews of any environment with other people so that they may test it:

  1. In the Environments list, find the entry for the environment you would like to share a preview of.
  2. Click the Actions menu.
  3. Select Share Link.
  4. Copy the preview link and send it to a colleague.
As an alternative to dedicated server environments that have each environment's respective container snippet installed, you can use the share preview function for each environment that you'd like to preview. With this method, you don't have to install and deploy a special environment code snippet, but you do have to remember to enable preview mode. Learn more about preview and debug mode.

Edit environments

To edit an environment:

  1. In the Custom Environments list, find the entry for the environment you would like to edit.
  2. Click the Actions menu.
  3. Select Edit Settings.
  4. Make changes to Name, Description, and Default URL as desired. Toggle the Enable Debugging by Default checkbox as desired.
  5. Click Save.

Revoke authorization code

If you have preview links sent out and you'd like to invalidate that preview, you can do so from the Actions menu:

  1. In the Custom Environments list, find the entry for the environment you would like to install.
  2. Click the Actions menu.
  3. Select Reset Link.
  4. A confirmation box will appear. Click Reset and Relink to cancel the old code and create a new one.

Note: This also will invalidate any container snippets that may be installed. This means that once an environment has had its authorization code revoked, an updated container snippet will need to be installed on the environment's server.

Versions

When you have environments defined, the Versions list will now show an Environments column, that indicates to which environment the version was published.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
7515562295054682016
true
Search Help Center
true
true
true
true
true
102259
false
false