Search
Clear search
Close search
Google apps
Main menu

Environments

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

You can define multiple server environments in Google Tag Manager. This feature is ideal for organizations that want to test their container changes in a test environment before publishing those changes to their live site, and for organizations that are using multi-tiered environments in their development workflow (such as 'development', 'staging', and 'production'.)

In this article:

Setup overview

Use the following steps to set up multiple environments in 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 will be able to set up as many environments as is required for your workflow, and you will be able to publish any version of your container to any environment you have defined. You may then send preview links to share with others for testing purposes.

Note: Another way to load environments onto your site is to use the environment's preview feature. This method will put your browser into preview mode by sharing the preview of whatever version of the environment you'd like to preview. In this way, the full features of environment testing can be had, without having to install/deploy a special environment snippet. See more about sharing previews below.

Define environments

The first step is to define your environments. This usually begins with a naming exercise, and often this is already established by your development team prior to the work of setting up multi-environment testing with Tag Manager.

For example, here is one example of a commonly-used server naming 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 before being published to production.
  • 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 will always point to the container version that is currently published. You don't need to define this additional environment. 

Once you have your naming convention established, you can set up custom environments in Google Tag Manager:

  1. Click on Admin.
  2. In the Container menu, select Environments.
  3. Click New. The Create New Environment box should appear.
  4. Enter a Name for your environment. Description and Default URL are optional.
  5. Optional: Check Enable Debugging by Default.
  6. Click Create. Your new environment should now appear in the Custom Environments listing.

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.
  3. Select Get Snippet.
  4. Copy the resulting code snippet.
  5. Install the snippet.
  6. 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 high volume 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 listing, 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.

Now when your environment is requested it will represent the selected version of your container.

Share previews

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

  1. In the Environments listing, find the entry for the environment you would like to share a preview of.
  2. Click the Actions menu.
  3. Select Share Preview.
  4. Copy the indicated preview link and send it to a colleague for testing.

Edit environments

You may edit an existing environment definition:

  1. In the Custom Environments listing, 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 listing, 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, indicating to which environment the given version was published.

Was this article helpful?
How can we improve it?