Custom Events
Track custom user interactions with the Fusionaly API
For custom events, user actions, or additional data collection, you can use our JavaScript API.
Custom Events
Section titled “Custom Events”Track specific user interactions or milestones not covered by automated tracking using the sendCustomEvent function.
Syntax: Fusionaly.sendCustomEvent(eventName, metadata)
- eventName (string): A unique name for your event (e.g., “trial_started”, “file_downloaded”).
- metadata (object): An object containing any additional dynamic information relevant to the event. You can include any key-value pairs, for example,
{ plan: "premium", fileName: "report.pdf" }. This data will be available in your analytics.
Example:
Fusionaly.sendCustomEvent("video_played", { videoTitle: "Product Demo", durationWatched: "60s",});Manual Page Views
Section titled “Manual Page Views”SPA frameworks could fail to automatically trigger page views changes, you can do it manually like this:
window.Fusionaly.sendPageView();Common Use Cases
Section titled “Common Use Cases”Track Form Submissions
Section titled “Track Form Submissions”document.querySelector('#contact-form').addEventListener('submit', function(e) { Fusionaly.sendCustomEvent('form_submitted', { form_name: 'contact_form', form_type: 'inquiry' });});Track Video Engagement
Section titled “Track Video Engagement”video.addEventListener('play', function() { Fusionaly.sendCustomEvent('video_started', { video_id: 'demo-video', video_title: 'Product Demo' });});
video.addEventListener('ended', function() { Fusionaly.sendCustomEvent('video_completed', { video_id: 'demo-video', video_title: 'Product Demo' });});Track Feature Usage
Section titled “Track Feature Usage”function onFeatureUsed(featureName) { Fusionaly.sendCustomEvent('feature_used', { feature: featureName, timestamp: new Date().toISOString() });}