basics
peasy has three methods that you can use to track events and manage visitor profiles: track, page, and setProfile. additionally, you can set attributes like data-peasy-event to track clicks and other browser events.
track custom events
The track method allows you to track custom events within your application. This is useful for monitoring specific actions that users take, such as completing a purchase or signing up for a newsletter.
peasy.track('order_created', {
order_id: 123,
total: 100
});
manually track page views
The page method is for manually tracking page views when the data-auto-page-view option is set to false.
peasy.page();
set visitor profile
the setProfile method allows you to set or update the profile of a visitor. great for tracking your authorized users.
peasy.setProfile('123', {
name: 'John Doe',
avatar: 'https://yoursite.com/images/avatar.png'
});
form submission tracking
peasy can automatically track form submissions with detailed field data:
<form data-peasy-event="signup_form_submit" data-peasy-event-form_type="newsletter">
<input type="email" name="email" />
<input type="text" name="name" />
<input type="password" name="password" />
<input type="checkbox" name="receive_newsletter" />
<input type="text" name="sensitive" data-peasy-ignore />
<button type="submit">Submit</button>
</form>
the form submission event will include:
- all non-empty field values (except passwords and fields with the
data-peasy-ignoreattribute) - the form's action url
- any additional data-peasy-event-* attributes
- checkbox and radio button states
click tracking
track element clicks with custom metadata:
<!-- Simple button tracking -->
<button data-peasy-event="login_click">Log In</button>
<!-- With dynamic attributes -->
<button
data-peasy-event="purchase_click"
data-peasy-event-product_id="123"
data-peasy-event-price="99.99"
data-peasy-event-currency="USD"
>
Buy Now
</button>