Custom events
Send your own events with taystack(name, properties): what names and properties are accepted, and the size limits.
Send an event
The script adds one global function, taystack. Call it with an event name and, optionally, an object of properties. There is no HTML-attribute shortcut for your own events: they are sent by this JavaScript call. The only events the script sends by itself are the opt-in link events described in Quick start.
document.querySelector('#signup').addEventListener('click', () => {
taystack('signup_click', { plan: 'pro', source: 'pricing_page' })
})Event names
- Must be a non-empty string. A call with anything else is ignored without an error.
- Up to 64 characters. The script cuts a longer name to 64.
- Letters, digits, spaces and
_ : . -only. A name with any other character is refused by the server (answer 400) and the event is lost. identifyis reserved: it sends an identify event instead, see Identify users.
Properties
- An object whose values can be written as JSON.
- At most 4096 characters once written as JSON. A larger object is refused by the server (answer 400) and the whole event is lost, so keep properties small.
- If the second argument is not an object (a string, a number or an array), it is replaced by an empty object.
- Properties are stored with the event.
Calling before the script has loaded
The script loads with defer, so taystack does not exist until it has run. To call it earlier, add this stub before the script tag. The script replays the queued calls when it starts.
<script>
window.taystack =
window.taystack ||
function () {
;(window.taystack.q = window.taystack.q || []).push(arguments)
}
</script>Note: Events are only sent from your registered domain, like pageviews. To use an event as a goal, see Goals and funnels.