Skip to content

JavaScript API

Track dynamic interactions that HTML attributes cannot express

Most tracking works with data attributes. You do not need JavaScript for that. Use this API for dynamic data that HTML attributes cannot express.

Use this to track interactions where the data is known only at runtime.

Syntax: Fusionaly.sendCustomEvent(eventName, metadata)

  • eventName (string): A unique name for your event. For example: trial_started, file_downloaded.
  • metadata (object): Extra data about the event. Add any key-value pairs, for example { plan: "premium", fileName: "report.pdf" }. This data appears in your analytics.

Example:

Fusionaly.sendCustomEvent("video_played", {
videoTitle: "Product Demo",
durationWatched: "60s",
});

If your SPA does not trigger automatic page views, call this function yourself:

window.Fusionaly.sendPageView();

This is the simplest way. You do not need JavaScript:

<form data-fusionaly-event-name="contact_form_submitted">
...
</form>

See Tracking for details.

For dynamic form data that HTML attributes cannot express:

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()
});
}