Events Tracking
Track Custom Events
Custom events allow you to track specific user interactions that matter to your business, such as:
- Button clicks
- Form submissions
- Feature usage
- Video plays
- Downloads
By tracking these events, you can understand user behavior and make data-driven decisions.
Implementation
Use the trackEvent()
function to log custom events:
// Basic event tracking
window.trackflow.trackEvent('button_click');
// With properties
window.trackflow.trackEvent('signup_completed', {
method: 'email',
referrer: document.referrer,
plan: 'pro'
});
// Tracking elements
document.querySelector('#signup-button').addEventListener('click', function() {
window.trackflow.trackEvent('signup_button_clicked');
});
Best Practices
Naming Conventions
Use consistent naming for events to make analysis easier:
- Use snake_case for event names (e.g.,
button_clicked
) - Be specific but concise
- Use a verb_noun pattern (e.g.,
form_submitted
)
Event Properties
Include relevant properties with your events:
- Only include useful information
- Avoid personally identifiable information
- Keep property values consistent