Skip to content
Facebook Twitter Github RSS
Google Tag Manager for WordPress
  • Home
  • FeaturesExpand
    • Basic features of GTM4WP

      You can use many post or page attribute in you Google Tag Manager setup even for custom post types and taxonomies.

      Basic data

      Page / post attributes

      Site search

      User data

      Multisite data

      3rd party data

      Browser attributes

      Device attributes

      Operating system attributes

      Weather conditions

  • SetupExpand
    • Setup advanced GTM4WP features

      Integrate your measurement with WooCommerce, setup Google Analytics 4, Google Ads remarketing or conversion tracking maximizing capabilities.

      WooCommerce related

      Google Analytics 4

      Google Ads – Dynamic Remarketing

      Google Ads – Conversion tracking

      Google Ads – Enhanced Conversions

      Other setup articles

      Exclude WordPress admins

      Embedded media players

  • DevelopersExpand
    • Information for developers and WP managers

      There are several tools in GTM4WP to support your special needs and to adjust plugin behavior to your website or WooCommerce shop.

      Do you want to contribute with a bugfix or a new feature? Visit the GTM4WP’s GitHub page!

      For Developers

      Actions and filters

      WP themes + Proper ecommerce tracking

      For WP managers

      Setup GTM Environments

      Hard code GTM parameters

  • Blog
  • GDPR
Download
Google Tag Manager for WordPress
Home / GTM4WP For Developers / Setup Google Tag Manager Environments using GTM4WP

Setup Google Tag Manager Environments using GTM4WP

Google Tag Manager Environments is an advanced feature that allows you to publish different container version into different versions of your website. Environments are useful for organizations that use multi-tiered environments in their development workflow.

You may use a separate “development” version where programmers can easily improve site feature without risking the operation of your live site. It is usually also a good idea to have a “testing” or “sandbox” version where plugin updates can be tested before you upgrade them on your live site. This can prevent you from breaking the site when some new plugin version conflicts with another plugin or the theme itself. This can also allow you to test new improvements and changes in your Google Tag Manager container without the need to publish changes directly on your live site.

Please note: if you use environments in GTM4WP, only enter one GTM container ID in plugin options as currently only one container is supported if using environments.

This page shows you the steps you need to go through in order to setup your GTM environment in GTM4WP.

  • 1. Create your Google Tag Manager environments
  • 2. Get the environment parameters
  • 3. Find the gtm_auth parameter
  • 4. Find the gtm_preview parameter
  • Hard coding for better site migration opportunities

1. Create your Google Tag Manager environments

First of all, read this GTM help center article to learn how to create your separate environments within GTM.

2. Get the environment parameters

Visit Admin, then Environments under your container and click on the Actions button at the end of the environment, that you are currently setting up.

Access the Get Snippet menu to retrieve your Google Tag Manager environment parameters.

Select the Get Snippet option from the menu.

3. Find the gtm_auth parameter

Look at the first container code and locate the gtm_auth parameter in it. Copy the value of this parameter to your clipboard (note: the value might continue to show on a new line!)

Find the gtm_auth environment parameter in the container code.

Open GTM4WP options and navigate to the Advanced tab. Enter the value into the appropriate field.

4. Find the gtm_preview parameter

Look at the container code again and locate the gtm_preview parameter in it. Copy the value of this parameter to your clipboard.

Find the gtm_preview environment parameter in the container code.

Open GTM4WP options and navigate to the Advanced tab. Enter the value into the appropriate field.

Hard coding for better site migration opportunities

You can also hard code both the container ID and the environment parameters into your wp-config.php file using PHP constants.

© 2025 Google Tag Manager for WordPress - Privacy policy

  • WordPress.org plugin page
  • Plugin support
  • Plugin reviews
  • Home
  • Features
    • Basic features of GTM4WP

      You can use many post or page attribute in you Google Tag Manager setup even for custom post types and taxonomies.

      Basic data

      Page / post attributes

      Site search

      User data

      Multisite data

      3rd party data

      Browser attributes

      Device attributes

      Operating system attributes

      Weather conditions

  • Setup
    • Setup advanced GTM4WP features

      Integrate your measurement with WooCommerce, setup Google Analytics 4, Google Ads remarketing or conversion tracking maximizing capabilities.

      WooCommerce related

      Google Analytics 4

      Google Ads – Dynamic Remarketing

      Google Ads – Conversion tracking

      Google Ads – Enhanced Conversions

      Other setup articles

      Exclude WordPress admins

      Embedded media players

  • Developers
    • Information for developers and WP managers

      There are several tools in GTM4WP to support your special needs and to adjust plugin behavior to your website or WooCommerce shop.

      Do you want to contribute with a bugfix or a new feature? Visit the GTM4WP’s GitHub page!

      For Developers

      Actions and filters

      WP themes + Proper ecommerce tracking

      For WP managers

      Setup GTM Environments

      Hard code GTM parameters

  • Blog
  • GDPR
Search