Custom events & goals
Pageviews tell you where people go. Custom events tell you what they do: sign-ups, button clicks, form submissions, purchases, video plays. Goals turn those events, or visits to specific pages, into conversion rates on your dashboard.
Tracking clicks with no JavaScript
Add data-cinder-event to any element. Clicking it, or anything inside it, sends an event with that name:
<button data-cinder-event="Signup">Start free trial</button>
Every data-cinder-prop-* attribute becomes a prop you can break the event down by. Hyphens in prop names become underscores:
<button data-cinder-event="Signup" data-cinder-prop-plan="pro" data-cinder-prop-billing-cycle="yearly">
Start free trial
</button>
This sends Signup with { "plan": "pro", "billing_cycle": "yearly" }.
Links work the same way. The event is sent with keepalive, so it survives the page navigating away and you don't need preventDefault:
<a href="/pricing" data-cinder-event="CTA clicked" data-cinder-prop-location="hero">See pricing</a>
Elements added after the page loads are tracked too, so this works with React, Vue, Alpine and Livewire without any extra setup.
Tracking form submissions
Put the attribute on the <form> and the event is sent when the form is submitted, not when a field inside it is clicked:
<form action="/contact" method="post" data-cinder-event="Contact form" data-cinder-prop-topic="sales">
…
</form>
To track every form on your site without editing each one, add data-form-submissions to the script tag instead. Each submit sends Form: Submit with the form's id or name as the form prop.
When you can't add data attributes
Some page builders and CMSs only let you add CSS classes. Use cinder-event-name= for the event name and cinder-event-<prop>= for props. Use + for spaces:
<a href="/pricing" class="button cinder-event-name=CTA+clicked cinder-event-location=hero">See pricing</a>
Tracking from JavaScript
The script defines cinder.track(name, props):
cinder.track('Signup', { plan: 'pro' })
To run code once the event has been sent, for example before redirecting, pass props and a callback:
cinder.track('Purchase', {
props: { sku: 'A1', plan: 'pro' },
callback: () => window.location.assign('/thanks'),
})
cinder('Signup', { plan: 'pro' }) works too, if you're moving over from a Plausible-style snippet.
Calling it before the script loads
Because the script loads with defer, cinder doesn't exist yet when your inline scripts run. Add this one-line stub after the snippet. Calls made before the script is ready are queued and sent once it loads:
<script>window.cinder=window.cinder||function(){(window.cinder.q=window.cinder.q||[]).push(arguments)};window.cinder.track=window.cinder.track||window.cinder</script>
TypeScript
declare global {
interface Window {
cinder: {
(name: string, options?: Record<string, string | number | boolean> | { props?: Record<string, string | number | boolean>; callback?: () => void }): void
track: Window['cinder']
pageview: () => void
}
}
}
Limits
- Event names can be up to 120 characters.
- An event can have up to 30 props.
- Prop names can contain letters, numbers,
-and_, up to 64 characters. - Prop values are stored as text, up to 300 characters.
trueand3become"true"and"3".
Props over the limits are dropped and the event is still counted. Don't send personal data such as email addresses in props.
Goals
Go to Settings → Analytics → Goals and add:
- a custom event goal, which counts visitors who sent an event with that name, or
- a pageview goal, which counts visitors who viewed a path. Use
*as a wildcard, like/blog/*or/thank-you*.
The Goals & events card on the dashboard shows each goal's unique visitors, total completions and conversion rate (unique converters ÷ all unique visitors). Click a goal to filter the whole dashboard to visitors who completed it.
You can also click any event under Custom events to see its props broken down, then choose Add as goal.
Testing your setup
Under Settings → Analytics, Send test event sends a real Test event to your project. It shows up under Custom events within a few seconds.