Tracking
The snippet
<script defer src="https://tally.example.com/t.js" data-site="YOUR_SITE_ID"></script>Find the site ID and a copy-ready snippet under Site settings → Tracking. The script is about 1.5 KB gzipped, never throws, and sets no cookies unless you ask it to.
To call tally(...) before the script has loaded, add this stub first; calls are queued and replayed:
<script>window.tally=window.tally||function(){(tally.q=tally.q||[]).push(arguments)}</script>Script attributes
| Attribute | Default | Meaning |
|---|---|---|
data-site |
required | The site's public ID |
data-api |
<script origin>/api/t |
Ingest URL (for first-party proxying, see proxy.md) |
data-persist |
off | Keep a persistent visitor ID in a first-party cookie |
data-cookie |
tally_vid |
Cookie name in persist mode (visitor keeps a visitors.now cookie) |
data-cookie-domain |
current host | For example .example.com to share the visitor across subdomains |
data-hash |
off | Count #/route changes as page views |
data-manual |
off | Don't send automatic page views; call tally.pageview() yourself |
data-outbound |
on | "false" turns off automatic Outbound Link events |
data-exclude |
none | Comma-separated path patterns not to track, such as /admin/*,/preview/* |
data-allow-localhost |
off | Track on localhost, 127.*, and file: pages |
JavaScript API
tally.track('Signup', { plan: 'pro', revenue: 49 }); // custom event; `revenue` (number, major units) feeds revenue reports
tally.identify({ id: 'user_123', email: 'ada@example.com', name: 'Ada', plan: 'pro' }); // `id` is required
tally.pageview({ path: '/checkout/step-2' }); // manual page view; the argument is optional
tally.reset(); // on logout: forget the persistent IDEvent rules: names up to 120 characters; up to 30 properties; keys up to 60 characters; values are strings (truncated to 500 characters), numbers, or booleans. Anything else is dropped.
window.visitors.track and window.visitors.identify point at the same functions, so code written for visitors.now keeps working.
Click events without JavaScript
<button data-tally-event="Signup" data-tally-plan="Pro" data-tally-source="hero">Get started</button>data-tally-event is the event name and every other data-tally-* attribute becomes a string property. data-visitors-event / data-visitors-* work too.
Links to other hosts send an Outbound Link event with { url } automatically (turn it off with data-outbound="false").
What gets sent
- A page view on load and on every History API navigation (
pushState, back/forward). Repeated URLs are skipped. Query strings are dropped on the server exceptutm_*,ref, andsource. - When the tab is hidden, an engagement
ping(at most once per 5 seconds of activity). It isn't stored as an event; it only extends the visit, so single-page visits get a duration. - Nothing at all when
localStorage.tally_ignore === "1"(exclude your own browser), for automated browsers (navigator.webdriver), during prerendering, on excluded paths, or on localhost withoutdata-allow-localhost.
Privacy model
- Cookieless (default). The server derives the visitor ID from a hash of a daily random salt, the site, the IP address, and the user agent. The salt rotates at midnight UTC and is deleted after two days, so IDs can't be recomputed later or linked across days. The one exception: a visit still going at midnight continues if the visitor carries on within 30 minutes. IP addresses and user-agent strings are never written to analytics tables: the IP is held in memory only while the event is processed (GeoIP lookup, hashing) and in the per-IP rate limiter, which forgets idle addresses within minutes. Outbound-link URLs are stored without their query string or fragment. This mode sets no cookies. Whether you need a consent banner depends on your jurisdiction and the rest of your site, so check with your own counsel.
- Persistent (
data-persist, or afteridentify()). A random ID in a first-party cookie identifies the browser across days. In the EU and UK this generally requires consent; load the script withdata-persistonly after consent, or callidentify()only for signed-in users who agreed to your terms. - Identified users.
identify()links the browser to a person record (email, name, and the traits you pass). Several browsers can belong to one person, which is how cross-device profiles work. Delete a person (optionally with their activity) from their profile page.
Safari caps cookies set by scripts at 7 days, so persistent IDs reset sooner there; identify() relinks them at the next sign-in.
Verified identify
identify() runs in the browser, so anyone who can read your snippet could call it with someone else's ID. To make profiles trustworthy, sign the ID on your server with the site's identify secret (Site settings → Tracking) and pass it as hash:
// Server (Node.js)
const hash = crypto.createHmac('sha256', process.env.TALLY_IDENTIFY_SECRET).update(user.id).digest('hex');// Page
tally.identify({ id: 'user_123', email: 'ada@example.com', name: 'Ada', hash: '<hash from your server>' });The id must be 1–200 bytes; identify calls with an empty or longer id are dropped (X-Tally-Status: dropped:invalid-identify), never truncated. Tally verifies the HMAC against the exact string it received (only NUL bytes and invalid UTF-8 are removed; whitespace is kept) and stores that same string as the person's ID. A numeric id is used as its JSON text, such as "123".
The hash is HMAC-SHA256 of the exact id string, hex-encoded (the same scheme as Intercom's identity verification). Any language works: hash_hmac('sha256', $id, $secret) in PHP, OpenSSL::HMAC.hexdigest('SHA256', secret, id) in Ruby, hmac.new(secret, id, sha256).hexdigest() in Python.
- Default (off): unsigned identify calls still link the browser to a person, and can create people, but they can never overwrite the email, name, or traits of a person that a signed call has identified.
- Require verified identify (on): unsigned identify calls are ignored (the endpoint answers
X-Tally-Status: dropped:unverified-identify).
Rotating the secret (Site settings → Tracking) breaks signed calls until your server uses the new value.
Revenue
Pass revenue (in major currency units, such as 49.99) with any event. It's stored in cents and shows up on the event, its visit, its source, and its person. The site's currency (Site settings → General) controls formatting only; Tally doesn't convert currencies.
Revenue sent from the browser can be forged, like any client-side analytics data. Treat it as an attribution signal, not accounting; server-side revenue (Stripe webhooks) is planned for v1.1.