Installation
How to install the Ometra tracking snippet, including SPAs and how to verify it's working.
Ometra is a single, lightweight script. Add it once to the <head> of your site.
The snippet
Copy your site's snippet from Settings → Install:
<script defer src="https://ometra.io/js/<your-site-token>.js"></script>
The token in the URL identifies your site, so the same snippet keeps working even if you change domains, or serve the same site from both example.com and www.example.com.
Legacy attribute snippet
We also support the classic attribute style, if you prefer to key on the domain:
<script defer data-domain="yourdomain.com" src="https://ometra.io/om.js"></script>
Google Tag Manager
If you manage tags through Google Tag Manager, add Ometra as a Custom HTML tag:
- In your GTM workspace, go to Tags → New → Tag Configuration → Custom HTML.
- Paste your snippet:
<script defer src="https://ometra.io/js/<your-site-token>.js"></script> - Under Triggering, add a trigger and choose All Pages (or Initialization - All Pages) so it loads on every page.
- Save, then Submit to publish your container.
GTM injects the tag itself, so the defer attribute is ignored — that's fine, it loads asynchronously either way. Because Ometra sets no cookies, you don't need to gate it behind consent, though you can attach a consent trigger if your setup requires one.
Single-page apps
The script automatically tracks route changes in single-page apps (using the History API), so you don't need to do anything extra for client-side navigation.
Excluding pages
To stop tracking certain paths, add a data-exclude attribute — a comma-separated list of path patterns, where * is a wildcard. This is especially useful when a marketing site and its app live on the same domain: because the script follows client-side (SPA) navigation, excluding the app paths keeps them out of your analytics.
<script defer
src="https://ometra.io/js/<your-site-token>.js"
data-exclude="/app*, /admin*, /account/settings"></script>
No pageviews or events are sent while a visitor is on a matching path.
Custom events API
Once the script is loaded, a global function is available for custom events:
window.ometra("Signup", { props: { plan: "pro" } });
Verifying it works
- Open Settings → Install — the status turns to "Receiving data" after your first event.
- Note that the script ignores traffic from
localhostby default. To test locally, add thedata-localattribute to the script tag. - The script also respects the visitor's Do Not Track and Global Privacy Control signals, and filters out known bots.
Do I need a cookie banner?
Because Ometra sets no cookies and stores no personal data, most sites won't need a consent banner for our analytics. Privacy law is fact-specific, though — confirm your obligations for your situation.