Installation
Run the CLI Wizard to set up Tranthor in your web project automatically:Usage
Tranthor’s web SDK is used to send events to Tranthor from the browser. Tranthor is an AI-native CRM for ecommerce brands.flush() never rejects, so awaiting it before a navigation cannot throw into your page.
Delivery options
init() also accepts these options:
Network errors and HTTP 408, 425, 429 and 5xx responses are retried. Other statuses, such as an
invalid write key (401), are dropped after one attempt and reported through
onError.
Visitors, privacy and consent
Events without auserId use an anonymous ID that the SDK stores in the visitor’s browser. After
identify(), later events carry the user ID as well. TranthorSdk.reset() clears both. If a
different user identifies in the same browser, the SDK first replaces the anonymous ID with a new one,
so the second user never inherits the first user’s anonymous activity.
TranthorSdk.optOut()stops tracking for the visitor and discards events that are still queued;optIn()resumes it. The choice is stored in the browser.- Set
respectDoNotTrack: trueininit()to stop tracking while the browser’s Do Not Track setting is on. It is read each time and never stored. - The page URL sent with each batch never includes the
#fragment.
Subscriptions
subscribe and unsubscribe add the visitor to, or remove them from, a subscription group:
userId or anonymousId. With the snippet, call _tr.subscribe(...) and _tr.unsubscribe(...).
Calls before init()
Calls to identify, track, page, screen, subscribe and unsubscribe made before init() are kept in memory, up to 100 events, and sent in order once the SDK is initialized. By default the SDK also sends what is queued when the visitor leaves the page; set flushOnPageHide: false in init() to turn that off.
This package is for the browser. On a server its tracking calls are ignored with a console warning;
use the Node.js SDK there.
Install the Snippet
You can also import the Tranthor snippet into your web app. This snippet will automatically load the Tranthor SDK and initialize it with your write key. This is convenient if you want to use the Tranthor SDK without a build system e.g. in a site builder like Webflow.Page tracking
The snippet does not send page events unless you turn it on. Setdata-auto-page="true" on the
script tag to send a page event on load and on every SPA route change (pushState,
replaceState, popstate). Any other value, or no attribute, leaves it off, and you call
_tr.page() yourself. A route change counts as a new page only when the page URL changes after
query stripping, so a change to the #fragment or to a parameter outside the allowlist sends
nothing. Automatic page events carry the page’s url, path, search, title and referrer as
properties; a manual _tr.page() sends only the properties you pass. With automatic tracking on,
drop your own _tr.page() calls, or each page is recorded twice.
Query strings
Query strings often carry reset tokens, email addresses and session IDs, so the snippet strips them from the page context of every event (track, identify, page and the rest), not only page events:urlandsearchare sent without the query string.https://shop.test/reset?token=abc#xis sent asurl: "https://shop.test/reset"withsearch: "".referreris always sent without its query string and#fragment.- To keep specific parameters in
urlandsearch, list them comma-separated indata-page-query-allowlist, for example"q,page"(spaces around names are ignored). Names match case-sensitively, and kept values are re-encoded (a space is sent as+). The allowlist does not apply toreferrer. - UTM parameters are read from the full URL before stripping, so
utm_source,utm_medium,utm_campaign,utm_termandutm_contentstill reachcontext.campaign. - A
context.pageyou pass yourself in a call is sent as you pass it, unstripped.
The npm package does the same from version 0.5.0. Pass the options to
init():
TranthorSdk.init({ writeKey, autoPage: true, pageQueryAllowlist: ["q", "page"] }). Earlier
versions send the query string as is and have no automatic page tracking.
