JavaScript API
Track dynamic interactions that can't be expressed in HTML attributes
Most tracking works with data attributes — no JavaScript needed. This API is for dynamic data that HTML can’t express.
sendCustomEvent
Section titled “sendCustomEvent”Track interactions where the data is only known at runtime.
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”If your SPA doesn’t trigger automatic page views, call this manually:
window.Fusionaly.sendPageView();Common Use Cases
Section titled “Common Use Cases”Track Form Submissions
Section titled “Track Form Submissions”The simplest way — no JavaScript needed:
<form data-fusionaly-event-name="contact_form_submitted"> ...</form>See Tracking for details.
For dynamic form data that can’t be expressed in HTML attributes:
Fusionaly.sendCustomEvent('form_submitted', { form_name: 'contact_form', plan_selected: selectedPlan});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() });}