Docs / Custom Events

Custom Events

Track exactly what users do on your site with custom events. For example, track when someone clicks "Buy", signs up, or submits a form. This helps you understand user behavior in detail.

Using HTML Attributes

The easiest way is to add the data-tiny-event attribute to any element. When someone clicks it, we'll automatically track the event:

html
<button data-tiny-event='Buy'>Buy Now</button>

Want to add extra details? Use additional attributes with thedata-tiny-event- prefix:

html
<button data-tiny-event='Buy' data-tiny-event-color='red'>Buy Now</button>

This adds a "color" property with value "red" to the event. You can add as many properties as you need.

Manual Tracking

You can also trigger events manually using JavaScript:

javascript
window.tinymetrics.track('Buy', { color: 'red' })

This creates a "Buy" event with a "color" property set to "red". Like with HTML attributes, you can include multiple properties.