Script configuration
Every attribute the snippet accepts, and the full browser API.
Script tag attributes
Only data-key is required. Everything else exists for cases where the default is wrong for you.
| Attribute | Default | What it does |
|---|---|---|
| data-key | required | Your project key. Starts with pk_ and is safe in public HTML. |
| data-endpoint | the script's own origin | Where events are sent. You almost never need to set this. |
| data-autotrack | true | Set to "false" to stop automatic page views and call termind.pageview() yourself. |
| data-localhost | false | Set to "true" to record visits on localhost while developing. |
| data-respect-dnt | false | Set to "true" to drop events from browsers sending Do Not Track. |
<script
defer
src="/pulse.js"
data-key="YOUR_KEY"
data-autotrack="false"
data-localhost="true"
data-respect-dnt="true"
></script>Why there is usually no endpoint to configure
The tracker works out where to send events from its own src attribute, not from the address of the page it is running on. Load it from /pulse.js and events go to your site. Load it from t.yoursite.com and events go there. Load it from our domain and they come straight to us.
This is the reason a proxy needs no second setting. Tools that resolve their endpoint against the page address instead have to be told the proxy URL separately, and forgetting it is a common way to end up with a proxy that loads the script correctly and then posts every event to a path on your own site that does not exist.
data-endpoint exists for the unusual case where the script and the ingestion endpoint are deliberately on different hosts. If you are following any of our proxy guides, leave it alone.
The browser API
| Call | What it does |
|---|---|
| termind.track(name, props) | Record a custom event. Appears under Goals. |
| termind.identify(id, traits) | Attach everything so far to a real person. |
| termind.group(id, traits) | Attach that person to an account or workspace. |
| termind.pageview() | Record a page view by hand. Only needed with autotrack off. |
| termind.reset() | Forget the current person. Call this on sign out. |
Use optional chaining, as in window.termind?.track(...). If the script was blocked, the global will not exist, and a hard reference would throw inside your own code.
Single page apps
The tracker patches pushState and replaceState and listens for popstate, so it sees client side navigation in React Router, Next.js, Vue Router and everything else built on the History API. You do not need a router hook, and adding one counts every page twice.
If your router does something unusual and views are being missed, set data-autotrack="false" and call termind.pageview() yourself at the point navigation completes. Do one or the other, never both.