Tiquo
API and AuthenticationDOM Package

Website Analytics

Track first-party website analytics with the DOM Package

Website Analytics

Website analytics starts automatically when you initialize TiquoAuth or TiquoCMS, unless you set analytics: false.

import { TiquoAuth } from '@tiquo/dom-package';

const auth = new TiquoAuth({
  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, and utm_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 auth.analytics?.track() to send custom analytics events from your website.

await auth.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:

OptionTypeDescription
eventNamestringHuman-readable event name
eventPropertiesobjectCustom structured event data
siteSlugstringOptional CMS website slug
pageSlugstringOptional page slug
pathstringOverride the current path
urlstringOverride the current URL
titlestringOverride the current document title
referrerstringOverride 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 auth.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 TiquoAuth or TiquoCMS.

const auth = new TiquoAuth({
  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',
});

Sur cette page