Custom events
Send your own events with properties from JavaScript or HTML attributes, and see what Trace already tracks automatically.
A custom event is any action on your site that Trace doesn't already know about on its own — clicking a "Sign up" button, submitting a form via JavaScript, upgrading a plan, completing step 2 of a wizard. Pageviews are tracked automatically; anything else needs you to tell Trace it happened.
Once an event is firing, its name shows up on the Events page and can be used as a goal, as a funnel step (through a goal) and as an alert trigger.
Send a custom event
Call the global datafast function with a name for the action and, optionally, properties that describe it:
window.datafast("signup");
// with properties
window.datafast("signup", {
plan: "pro",
billing: "yearly",
source: "pricing-page",
});- The first argument is the event name — there's no separate "event type" wrapper. This is the name you match against in a goal.
- The second argument is optional properties attached to that one event. Properties become breakdowns you can open and filter by.
Pick short, stable names in one style (signup, checkout_started) — every distinct name is its own row, so Signup and signup count separately. Put the variable part in a property, not in the name.
Calling it before the script has loaded
If your event might fire before script.js finishes loading, queue it with the stub from Install the tracking script. Queued calls are sent once the script is ready.
Without writing JavaScript
Clicks
Add data-fast-goal to any clickable element and a click (or Enter/Space on it) sends that event. Extra data-fast-goal-* attributes become its properties; dashes in the property name become underscores.
<button data-fast-goal="signup" data-fast-goal-plan="pro">
Start free trial
</button>Elements scrolled into view
data-fast-scroll on an element sends an event when the element scrolls into view.
<section
data-fast-scroll="pricing_seen"
data-fast-scroll-threshold="0.5"
data-fast-scroll-delay="1000"
>
…
</section>| Attribute | What it does |
|---|---|
data-fast-scroll | The event name to send. |
data-fast-scroll-threshold | How much of the element must be visible, from 0 to 1. Default 0.5. |
data-fast-scroll-delay | Milliseconds the element must stay in view before the event is sent. Default 0. |
data-fast-scroll-* | Any other suffix becomes a property of the event. |
The event also carries scroll_percentage (how far down the page the visitor was), threshold and delay. If the element leaves the viewport and comes back, it can fire again. Elements added to the page later are picked up automatically.
Tracked automatically
These arrive with no code from you. Each is listed on the Events page under its own name.
| Event | When it's sent | What's recorded | Turn off |
|---|---|---|---|
external_link | A click on a link to another site. | The destination (url) and the link's text (text). | — |
file_download | A click on a link to a file — pdf, zip, csv, docx, mp4, dmg and similar. | The file's address (url). | data-disable-file-downloads; change the list with data-file-types or data-add-file-types. |
form_submission | A form passes the browser's validation and is submitted. | The form's id and name attributes, if it has them, and the page. | data-disable-form-tracking |
payment | A visitor returns from a Stripe, Polar or Lemon Squeezy checkout, or you call window.datafast("payment", { email }). | The checkout reference or the customer's email. | data-disable-payments |
identify | You call window.datafast("identify", { user_id, … }). | The user's id, name, email, image and any other traits. | — |
Links to your own site — including other subdomains of the same domain, and hostnames listed in data-allowed-hostnames — aren't outbound, so they aren't counted.
Reserved names
These names have a special meaning and can't be used for your own events:
| Call | What it does |
|---|---|
window.datafast("identify", { user_id, … }) | Identifies a signed-in visitor. See Identify users. |
window.datafast("props", { … }) | Sets properties attached to every event for the rest of the page's life. It isn't an event itself. See Custom properties. |
window.datafast("payment", { email }) | Records a payment for the customer with that email. email is required. |
Limits
| Limit | Value |
|---|---|
| Properties per call | 10. A call with more is rejected with a console error. |
| Property names | Letters, numbers, underscores and hyphens, up to 32 characters. Names are stored lower-case. |
| Property values | Text up to 255 characters (longer values are cut). Numbers and booleans are stored as text; the characters < > ' " & are removed. |
| Properties per event | 30, counting the ones set for every event with window.datafast("props", …). Empty values and nested objects are dropped. |
| Event name | Up to 255 characters, cleaned the same way as property values. |
If a call breaks the rules for property names or count, the whole event is dropped rather than stored partly.
Checking what was sent
Add data-debug="true" to the script tag while testing: the browser console then says whether each event was sent, and why one was rejected.
FAQ
My event isn't showing up
- Tracking is off on localhost and
file://unless you adddata-allow-localhost="true"ordata-allow-file-protocol="true". - A call that breaks the limits above is dropped whole — turn on
data-debugto see why. - Check the date range and filters at the top of the page: the event has to fall inside both.
- Switch the event log to Realtime and trigger the event: it should appear within a couple of seconds.
- Open your browser's network tab and trigger the action: you should see a request go out. If nothing fires, the call isn't reachable from your code path, or it runs before the script loads and isn't queued.
Can I rename an event after I've been sending it?
Not automatically — goals match the exact event name. If you rename it in your code, update any goal using the old name too.
Can I use an event as a goal or a funnel step?
Yes — create a goal of type Custom event with the event's name (or external_link, file_download, form_submission or payment for the automatic ones) in Settings → Goals, then use that goal as a funnel step.
Do bots show up in events?
No. Known crawlers are kept on the Bots page, and automated browsers are ignored before anything is sent.