Documentation
Custom events
Name anything that matters and send it from the browser with one call.
Once the snippet has loaded it puts a single function on window. Call it with a name and, optionally, an object of properties.
// Anywhere in your app, after the snippet has loaded:
window.inqetra("subscription_cancelled", {
plan: "pro",
reason: "too_expensive",
});Naming
An event name must start with a letter or digit, then up to forty-eight more characters drawn from letters, digits, underscore, dot, colon or hyphen. The collector rejects anything else with a 400 and tells you the pattern it wanted.
Names are what you will be reading in six months, so they are worth a moment. subscription_cancelled says what happened; click_3 does not.
Reserved names
pageview and duration belong to the tracker, which emits both itself. A custom event using either name would be indistinguishable from the real thing in every breakdown that counts them, so the collector refuses it.
Calling before the script has loaded
The tracker is deferred, so a call during initial render can run before the function exists. If that is a risk in your app, define a queue ahead of it — the tracker drains it on load:
<script>
window.inqetra = window.inqetra || function () {
(window.inqetra.q = window.inqetra.q || []).push(arguments);
};
</script>Worth knowing
Anything sent from a browser is asserted by that browser, which means a determined visitor can send it too. For facts that have to be true — a payment settled, a plan changed — use server-side events, where the caller holds a key.