Website Analytics
Track first-party website analytics with the DOM Package
Website Analytics
Website analytics starts automatically when you initialize Tiquo, unless you set analytics: false.
import { Tiquo } from '@tiquo/dom-package';
const tiquo = new Tiquo({
publicKey: 'pk_dom_your_key_here',
});The SDK records cookie-free first-party analytics events to Tiquo, including:
- Pageviews, including the current path, URL, page title, and referrer
- Single-page app navigation through
history.pushState,history.replaceState, and browser back/forward navigation - Engagement events when the visitor leaves a page or the page becomes hidden
- Session attribution through a browser-session ID stored in
sessionStorage - UTM parameters from the current URL:
utm_source,utm_medium,utm_campaign,utm_content, andutm_term - Browser, device type, operating system, language, screen size, and viewport size
- Known-customer identity when the visitor authenticates through the DOM Package
Tiquo records the source hostname for each event. www.example.com is normalized to example.com; other subdomains are tracked separately.
Sending Custom Events
Use tiquo.analytics?.track() to send custom analytics events from your website.
await tiquo.analytics?.track('booking_started', {
eventName: 'Booking Started',
eventProperties: {
serviceId: 'svc_123',
locationId: 'loc_456',
},
});Custom events accept the same page context fields used by automatic pageviews:
| Option | Type | Description |
|---|---|---|
eventName | string | Human-readable event name |
eventProperties | object | Custom structured event data |
siteSlug | string | Optional website slug for analytics site resolution |
pageSlug | string | Optional page slug |
path | string | Override the current path |
url | string | Override the current URL |
title | string | Override the current document title |
referrer | string | Override the document referrer |
Identifying Customers
After a customer signs in with verifyOTP(), the SDK automatically sends an identify analytics event. The event includes the current access token so Tiquo can associate website activity with the authenticated customer.
You can also send an identify event manually when you link an analytics session to a customer through another flow:
await tiquo.analytics?.identify({
identityLinkType: 'email_capture',
});Supported identityLinkType values are auth_dom_login, email_capture, booking, enquiry, order, customer_portal, and manual.
Manual Pageviews
Automatic pageview tracking is enabled by default. If you need to control pageview timing yourself, create a standalone analytics instance with autoTrackPageviews: false.
import { TiquoAnalytics } from '@tiquo/dom-package';
const analytics = new TiquoAnalytics({
publicKey: 'pk_dom_your_key_here',
autoTrackPageviews: false,
});
await analytics.trackPageview({
path: '/pricing',
title: 'Pricing',
});Disabling Analytics
Set analytics: false when creating Tiquo.
const tiquo = new Tiquo({
publicKey: 'pk_dom_your_key_here',
analytics: false,
});Standalone Analytics
You can use TiquoAnalytics without authentication if a site only needs first-party website analytics.
import { TiquoAnalytics } from '@tiquo/dom-package';
const analytics = new TiquoAnalytics({
publicKey: 'pk_dom_your_key_here',
siteSlug: 'main-site',
});
await analytics.track('newsletter_signup', {
eventName: 'Newsletter Signup',
identityLinkType: 'email_capture',
});