Custom events
Send signups, purchases and clicks with a name and properties.
Pageviews tell you where visitors go. Custom events tell you what they do: sign up, start a trial, buy, download. Each event has a name and optional properties.
From React or Next.js
import { track } from '@ultanimus/react'
export function SignupButton() {
return <button onClick={() => track('signup', { plan: 'pro' })}>Sign up</button>
}The packages' track is safe to call before the script has loaded and during server rendering.
From the script tag
The script adds window.ultanimus.track to the page. Call it with a name and, if you want, properties.
<button onclick="ultanimus.track('signup', { plan: 'pro' })">Sign up</button>The script loads with defer, so your own code can run before it does. To send events that early, add this line above the snippet. Calls wait in a queue and go out as soon as the script starts, and a user you pass to identify goes with them.
<script>window.ultanimus = window.ultanimus || { q: [], track: (name, props) => window.ultanimus.q.push([name, props]), identify: (id) => { window.ultanimus.user = id } }</script>Links and downloads
Clicks on links to other sites and on files need no code. Add data-outbound or data-downloads to the snippet and the script sends outbound_link and file_download for you. See Links and downloads.
From your server
Send the same event with the Events API. Use the server for anything confirmed there, like a paid order, so a blocked or closed browser cannot lose it. Pass the same user ID as the browser's identify() and the event joins that person's open visit.
Name events well
- Use short, lower-case names:
signup,trial_start,purchase. - Put the part that varies in properties, not in the name:
purchasewith{ plan: 'pro' }, notpurchase_pro. - Keep names stable. A renamed event starts a new line in your charts.
Properties
Properties let you filter an event and break it down: by plan, by button, by page section. Keep values short and countable, like a plan name, rather than free text or IDs.
track('purchase', { plan: 'insight', billing: 'monthly' })
track('purchase', { order: 'ord_8f2k1x' })Share links and embeds never show properties.
See them in the dashboard
The Events page lists every custom event. Open one for its numbers, a chart and a tab for each property, and click a value to filter by it.
Any event can become a goal, and goals can be the steps of a funnel. See Goals and funnels.