GTM environments: keeping test traffic out of live data
A tester opens a staging site on Tuesday, clicks through a checkout, and the client's live GA4 property records a purchase. On Thursday the conversion rate drops and nobody can explain it. Tag Manager did exactly what it was told. The problem is that nobody had told it which server was which.
Three mechanisms get called "version control" in conversation: workspaces, versions and environments. They solve different problems, and mixing them up is how a QA click lands in a board report.
Workspaces are drafts, and the limit is real
Every container has a default workspace. Everything you change lives inside one, and nothing you change reaches a site until somebody publishes. Google allows three concurrent workspaces on a regular account: the default plus two custom ones. Tag Manager 360 accounts get an unlimited number, which is the first place the paid tier shows up in daily work rather than in a feature list.
Three is enough if you name them for the job. "GA4 checkout events" is a workspace that will produce a version of the same name. "Andy's changes" is a workspace that produces a version nobody can identify in six months. The name and notes you give a workspace are recorded with the version it becomes, so the naming decision you make on Monday is the documentation you rely on in March.
Publishing or versioning a workspace removes it, and the default workspace is recreated afterwards. That explains a confusion I hear often: there is no archive of finished workspaces to browse. The history lives in versions.
Workspaces also go stale. Each container has one stream of versions, so when anyone creates a version, every other workspace shows an out-of-date notice. If you publish without updating, Tag Manager merges in what changed elsewhere, and shows a conflict screen when the two edits touch the same element. The colour coding is worth knowing before you see it for the first time: blue means the element was modified between the last synced version and your workspace, red means the synced version has a modification your workspace lacks, green means your workspace has a modification the synced version lacks. For each conflict you keep your version or take the incoming one. What you ignore from the synced version is overwritten when you publish.
Versions are the rollback point
A version is a snapshot of the container configuration at a moment in time. You can save one without publishing, which is useful before a risky change, and every publish records one automatically. A new container starts with a version called "Version 1 - Empty Container".
The recovery path is the reason to care. Open Versions, pick the last good snapshot, and publish it. Tag Manager keeps a publish history, so the Published column shows when each version was live and who pushed it. That column has settled more than one argument about when a tracking problem started.
There is a second, subtler action. "Set as Latest Version" replaces the current draft with the content of an older version. That is the move when a workspace has drifted somewhere unhelpful and you want to rebuild from a known state rather than unpick it by hand. Note the difference: publishing a version changes what runs on the site, and setting it as latest changes what you are editing. Doing both in the wrong order loses work.
One permission detail catches people out. Creating a version needs Approve access or higher. An editor can build the whole change and still not be able to save it as a version, which is either a problem or the control you were looking for, depending on who you are.
Environments decide which server gets which version
This is the part that actually separates staging from production. Every container has a Live environment that always points at the currently published version. You cannot create it, edit it or delete it. Custom environments are the ones you add.
Creating one takes a name, an optional description, an optional destination URL, and an optional "Enable Debugging by Default" switch for environments that should always open in preview mode. Google's own guidance suggests a Dev, QA, Live split: Dev for day-to-day build work, QA as a gate that changes must pass before they are considered ready, and Live for the site the public sees.
The mechanics that matter: publishing to a custom environment does not touch the live version. The changes are only visible on a server that has that environment's own container snippet installed, or in a browser using the share preview link. You get the snippet from the environment's Actions menu. You can pin an environment to any version with Publish To, so QA can sit on version 41 while live runs version 43. The Versions screen grows an Environments column once you use any of this, which makes the picture readable at a glance.
Google is explicit that environments are for non-production work, and that live sites should carry the standard container snippet rather than an environment snippet. Treat a custom environment as a test harness, not as a way to run production.
A shared preview link is a credential
Share Link gives you a URL that opens a specific environment's version in preview, with no snippet installation needed. It is the fastest way to get a client to sign off on a change, because they see their own site with the new tags on it.
It is also an access token. Reset Link revokes the old authorisation code and issues a new one, which invalidates any container snippets already installed for that environment. After a reset, the server needs the updated snippet before it reports anything again. Rotate preview links when a contractor leaves, and expect to reinstall the snippet when you do.
What environments do not do
Here is the gap that produces polluted data. An environment separates container versions across servers. It does not separate data destinations. A staging container published to a Dev environment, carrying a GA4 tag pointed at the client's production measurement ID, sends staging hits to the production property the moment the QA server loads it. The environment did its job. The tag still pointed at the wrong place.
The fix is a variable that knows where it is running. Tag Manager has a built-in Environment Name variable. Google's description of its behaviour is precise and slightly awkward: it returns the environment name when the request comes from an environment snippet or a share preview link, returns "Live", "Latest" or "Now Editing" for the built-in environments, and returns an empty string in all other cases.
That empty string is the whole design problem in one value. Build a lookup table on Environment Name with your staging property for the Dev and QA names, and give the lookup a default value of the production ID. Then an unrecognised or empty environment resolves to production rather than to nothing, which is the safer failure for a measurement tag. Reverse it and a broken environment silently stops collecting.
Check the lookup in preview on the staging server, not in your head. Before publishing to a QA server, confirm that server resolves to the property you expect, because the client's property is the one you cannot undo.
Approvals exist, but only on 360
If you want a formal sign-off before publishing, you need Google Tag Manager 360, which ships with the Google Marketing Platform. Free and standard accounts do not have it, and no amount of clicking in the interface adds it.
On 360 the workflow is a proper request system. Anyone with Edit access or higher can request approval from the Submit screen, assign a specific reviewer, and leave a comment explaining the change. Anyone with Approve or Publish access can act on the request, and the Approvals tab flags open requests with a blue circle for items available to anyone or assigned to somebody else, and a red circle for items waiting on you. The reviewer approves, sends it back for further edits, or withdraws it. Approvals cover publishing workspaces, external account links, and tags pushed from Campaign Manager 360.
Without 360, you build the same discipline out of permissions, and it works better than most agencies expect.
The permission ladder is a publish gate
Container access comes in five levels. No access means the container is invisible. Read allows browsing but no changes. Edit allows creating workspaces and editing, but explicitly not creating versions or publishing. Approve allows versions, workspaces and edits, but not publishing. Publish allows all of it.
Read that ladder as a workflow rather than a hierarchy of seniority. A junior analyst with Edit can build and test a change but cannot turn it into a version. A senior with Approve can turn it into a version but cannot push it. The account owner with Publish is the only person who can make it live. Two people are now required to ship anything, on a free account, with no configuration beyond user management.
Account and container permissions are separate. At account level a user is either User or Administrator, where Administrator can create containers and change permissions. Below that, container permissions are granted per container, and a level is described as inherited when it arrives through an account role rather than a direct grant. Two operational habits follow. Keep at least two active administrators, because Google raises a Tag Diagnostics notification when an account has only one, and a single admin who leaves takes the whole setup with them. And have the client organisation hold the account, with the agency at container level. Google says as much directly: make sure the account is managed by someone in your organisation, not an external agency.
A setup that holds up
- Agree who owns the account. Client organisation at account level, agency at container level with Edit, Approve or Publish as appropriate.
- Create Dev and QA environments, install the environment snippets on those servers, and pin each to a known version.
- Add a lookup table on Environment Name that routes staging to a staging measurement ID, with production as the default.
- One workspace per job, named as the version you will want to read later.
- Publish with a version name that states the change, not the date. The date is already recorded.
- If a publish goes wrong, open Versions, pick the last good snapshot and publish it. Keep the bad version rather than deleting it, because the record is the evidence.
- Rotate share preview links quarterly and whenever someone with access leaves.
None of this is exotic. It is the difference between a container a team can work on and a container one person understands. The test click that lands in a client's conversion count is not a tagging bug in the usual sense. It is a governance hole with a tag on top, and it costs a morning to close.
Not sure whether test traffic is reaching your live reports? Book a free tracking audit and we will check your container versions, environments and publish permissions before they cost you a quarter of data.