Plain HTML
Install in plain HTML
Add the tag to the <head> of every page, and the rewrite on your host:
<script defer src="/_t/t.js" data-site="mysite"></script>If you cannot add a rewrite, point both URLs at the Trail host instead. Ad blockers are more likely to stop it this way.
<script defer src="https://stats.example.com/_t/t.js" data-site="mysite"
data-api="https://stats.example.com/_t/e"></script>Track an event in plain HTML
<button data-trail="Signup">Sign up</button>
<script>
// or from code, once the tracker has loaded
document.querySelector('#newsletter').addEventListener('submit', () => trail.track('Newsletter'));
</script>Set consent in plain HTML
The tracker is private until consent. Call trail.consent(true) from your banner's accept button and trail.consent(false) from decline. To skip consent, set data-mode="full" or data-mode="private" on the tag. See Privacy modes and consent.
Avoid double pageviews in plain HTML
Each page load is one pageview. If your site swaps pages with JavaScript and the History API, those count too; do not call trail.pageview() as well.
Verify the plain HTML install
Load a page. The network panel should show POST /_t/e answered with 204, and the dashboard header should show 1 online. On localhost, add data-dev (dev in code) and pick All Environments in the dashboard. If nothing arrives, see Troubleshooting.
Next
- Track events and named clicks.
- Pick a privacy mode.
- Read your numbers in the dashboard.
Reviewed on 2026-11-20 against trail-analytics 0.2.0.