Skip to content

Track custom events

Send your own events, like sign-ups and purchases, with properties.

Page views are tracked for you. For anything else that matters, like a sign-up, a purchase or a search, send a custom event with track().

Before you start

  • Loomduct installed on your site. See the Quick start.

Send an event

Call track() with an event name, and properties if you want them:

src/checkout.ts
import { loomduct } from './loomduct'

loomduct.track('signup')

loomduct.track('purchase', {
  plan: 'pro',
  price: 49,
  trial: false,
})

With the script tag, the snippet creates window.loomduct, so you can call loomduct.track() from any script on the page, also before the SDK has loaded.

Rules for names and properties

WhatRule
Event nameNot empty, at most 200 characters, cannot start with $.
PropertiesAt most 30 on one event.
Property keyAt most 128 characters, cannot start with $.
Property valueText (at most 2,000 characters), a number or true/false. No objects, arrays or null.

Properties set to undefined are left out. Events that break these rules are not recorded. In development builds, the SDK warns in the browser console; in production, your onError function gets an invalid_event error.

Pick names that say what happened, in the same style everywhere, like signup, purchase, plan_upgraded.

Check that it worked

Trigger the event on your site. In the dashboard, open Events. Your event shows up in the list within a few seconds. Open it to see its properties.