Skip to content

Automated Tracking

Learn what Fusionaly tracks automatically

By default, Fusionaly automatically tracks the following without any additional code:

Every page load is automatically tracked.

The SDK automatically detects navigation changes in SPAs by monitoring history state and popstate events, treating them as new page views. It supports React, Vue, and Angular.

When auto-instrumentation is enabled (default), clicks on <button> elements, <input type="button">, <input type="submit">, and any element with role="button" are automatically tracked.

By default, button events are named using the pattern: click:button:sanitized_text:button_id. Here’s how it’s constructed:

  • sanitized_text: Derived from the button’s visible text. The system prioritizes textContent, then value, then title. This text is then sanitized: converted to lowercase, spaces replaced with underscores, non-alphanumeric characters (except underscores) removed, and truncated to 50 characters. If no text is found or sanitization results in an empty string, it defaults to “unnamed_button”.
  • button_id: The id attribute of the button. If the button has no ID, this defaults to “noid”.

For example, <button id="myBtn">Submit</button> would generate an event named click:button:submit:mybtn.

You can override the automatic naming by adding the data-fusionaly-event-name attribute to your button. This is useful for standardizing event names across your application or tracking specific user actions.

<button data-fusionaly-event-name="newsletter_signup">
Subscribe to Newsletter
</button>
<button data-fusionaly-event-name="download_started">Download App</button>

Add custom metadata to button events using data-fusionaly-metadata-* attributes. This allows you to capture additional context about the user’s action.

<button
data-fusionaly-event-name="product_purchased"
data-fusionaly-metadata-product="premium_plan"
data-fusionaly-metadata-price="29.99"
data-fusionaly-metadata-billing="monthly"
>
Buy Premium Plan
</button>

You can automatically track purchases by setting data-fusionaly-event-name="revenue:purchased" on buttons. This creates standardized purchase events that integrate with your revenue analytics. See the Purchase Tracking section for complete details and examples.

Note: If an <a> tag is styled like a button but includes the data-fusionaly-event-name attribute, it will be handled by Link Event Tracking (see below) to avoid duplication, and this general button tracking will defer.

Track clicks on specific links declaratively by adding data- attributes to your <a> tags. This is useful for CTAs or important navigational elements. This method takes priority over general button click tracking for <a> tags to prevent double counting.

  • Activation: Add data-fusionaly-event-name to the link.
  • Event Naming: The value of data-fusionaly-event-name is used directly as the event name (no sanitization for custom names).
  • Automatic Metadata: href (link URL) and text (link text).
  • Custom Metadata: Use attributes like data-fusionaly-metadata-yourkey="value".

For links that navigate to other pages, the SDK automatically uses navigator.sendBeacon() to ensure the event is sent even if the user navigates away immediately. This provides reliable tracking for navigation events.

<a
href="/#features"
data-fusionaly-event-name="clicked_features_link_from_docs"
data-fusionaly-metadata-location="docs_page_section"
data-fusionaly-metadata-custom_id="feat_123"
>
Explore Our Features
</a>
<!-- Track external link clicks -->
<a
href="https://partner.com"
data-fusionaly-event-name="external_link_clicked"
data-fusionaly-metadata-partner="partner_name"
>
Visit Partner Site
</a>
<!-- Track download links -->
<a
href="/downloads/whitepaper.pdf"
data-fusionaly-event-name="whitepaper_downloaded"
data-fusionaly-metadata-format="pdf"
>
Download Whitepaper
</a>
<!-- Track CTA clicks -->
<a
href="/signup"
data-fusionaly-event-name="cta_clicked"
data-fusionaly-metadata-location="header"
>
Get Started
</a>