Automated Tracking
Learn what Fusionaly tracks automatically
By default, Fusionaly automatically tracks the following without any additional code:
Page Views
Section titled “Page Views”Every page load is automatically tracked.
Single-Page Application (SPA) Navigation
Section titled “Single-Page Application (SPA) Navigation”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.
Button Clicks
Section titled “Button Clicks”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.
Automatic Event Naming
Section titled “Automatic Event Naming”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, thenvalue, thentitle. 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
idattribute 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.
Custom Event Names
Section titled “Custom Event Names”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>Custom Metadata
Section titled “Custom Metadata”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>Purchase Tracking
Section titled “Purchase Tracking”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.
Link Event Tracking
Section titled “Link Event Tracking”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-nameto the link. - Event Naming: The value of
data-fusionaly-event-nameis used directly as the event name (no sanitization for custom names). - Automatic Metadata:
href(link URL) andtext(link text). - Custom Metadata: Use attributes like
data-fusionaly-metadata-yourkey="value".
Navigation Links
Section titled “Navigation Links”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.
Basic Example
Section titled “Basic Example”<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>Common Use Cases
Section titled “Common Use Cases”<!-- 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>