Skip to content

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.

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",
});

If your SPA doesn’t trigger automatic page views, call this manually:

window.Fusionaly.sendPageView();

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
});
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'
});
});
function onFeatureUsed(featureName) {
Fusionaly.sendCustomEvent('feature_used', {
feature: featureName,
timestamp: new Date().toISOString()
});
}