Environments and releases
You may run the same site in several places: the live site, a staging site, a developer’s machine. Each event says which place sent it (its environment) and which version of your site (its release). Reports show one environment at a time, so a test site never mixes into the live numbers.
Name them on the script tag
Section titled “Name them on the script tag”Add data-environment and data-release to the tracker’s script tag:
<script defer src="https://analytics.example.com/t.js" data-key="pk_…" data-host="https://analytics.example.com" data-environment="staging" data-release="1.4.2"></script>Both are optional. Every event from the page carries them.
| Attribute | Rule | Without it |
|---|---|---|
data-environment |
1 to 64 letters, digits, ., _, or -, starting with a letter or digit, such as production, staging, or pr-142. Ottertrail stores it in lower case, so Staging and staging are one environment. |
Events count as production. |
data-release |
1 to 200 characters, without spaces or control characters, as you name your versions: 1.4.2, web@2026.11.17+3f2a9c1, a commit hash. Stored as you send it. |
Events have no release. |
The tracker checks both values as the instance does:
- With an invalid environment, the tracker sends nothing and writes a warning in the browser’s console. Its events would otherwise count as
production. - With an invalid release, the tracker leaves the release out, writes a warning, and sends the events.
So leave data-environment out on the live site, and set it on every other site. Set data-release from your build, so that it changes with each version. Source maps and errors use the same release: see Upload source maps.
Server-side events name their environment and release in the request body. See Server-side events.
Choose the environment in a report
Section titled “Choose the environment in a report”Reports show production unless you choose another environment. Once another environment has events in the period, the filter bar shows a second picker with the environments that have events, most events first. While another environment than production is shown, the picker stays, so there is always a way back.
- The environment goes in the page’s address as
env=staging. It is left out forproduction. - Switching the environment keeps the period and the filters.
- An environment is not a filter. It decides where the report looks, as the project does. Events of other environments never mix in.
The Web analytics, Speed, Product analytics, Users, and Errors pages, and the monitoring pages, also show one environment at a time. Visits are worked out for one environment at a time too: a developer who opens the live site and then the staging site makes two visits, not one.
The Releases table
Section titled “The Releases table”On the Web analytics page, the Releases table lists the release of each visit’s first event, most visitors first. Select a release to filter the page by it: every figure and table then counts the visits that started on that release.
While no visit in the period names a release, the table says how to add data-release instead of listing every visit as “Unknown”. Once some do, visits without a release show as “Unknown”.
See Web analytics reports for the other tables and filters.