Track Events
Track custom events in Pieowl to measure what users do, like clicks, sign-ups and purchases.
Events are the core of Pieowl. An event records one action a user takes, like clicking a button, sending a form or buying something.
The examples below use pieowl, the SDK instance you created during install. With the script tag, use window.pieowl instead. It works once pieowl.js has loaded; to call it earlier, use the window.pieowl('track', ...) form and add the queue line before the script tag.
Tracking an event
Call track with an event name.
pieowl.track('button_clicked');With the script tag:
window.pieowl('track', 'button_clicked');Adding properties
Pass a properties object to add context to the event.
pieowl.track('signup_button_clicked', {
location: 'header',
color: 'blue',
variant: 'primary'
});Common property types
- Strings: Text values like names, categories or IDs.
- Numbers: Numeric values like price, quantity or score.
- Booleans: True or false values.
Using data attributes
You can track clicks without writing JavaScript. Add a data-track attribute to a button or link. This needs Clicks you marked in your code to be on in Settings → Site (it is by default).
<button
data-track="signup_clicked"
data-location="header"
>
Sign Up
</button>When a user clicks this button, Pieowl tracks a signup_clicked event with the property location: 'header'. Every other data-* attribute on the element becomes a property, with its name in camelCase (data-plan-name becomes planName).