Skip to main content

Auto Start Tracking

Auto tracking is enabled by default. This is ideal for straightforward setups where you prefer hands-off integration. If you need more control (e.g., for conditional tracking or custom event triggers), disable this option and implement your own tracking logic using the provided API methods, such as trackPageView() or event handlers.
  1. Go to the menu on the top right and navigate to Settings
  2. Click Sites.
  3. Select the desired site.
  4. Enable/Disable Auto start tracking.
  5. Don’t forget to click Save at the bottom of the page.

SPA Modes

For Single Page Applications, where content updates dynamically without full page reloads, Axo Analytics offers flexible SPA modes to ensure proper tracking of virtual page views and navigation changes. Choose the mode that best matches your app’s routing mechanism:
  • none: Disables SPA-specific handling. Use this for non-SPA sites or when you plan to manually trigger tracking on route changes. No automatic detection of history or hash events occurs.
  • auto: Automatically detects and handles SPA navigation. This mode intelligently monitors both history API changes and hash routing, making it a versatile default for most modern frameworks like React, Vue, or Angular without requiring extra configuration.
  • history: Focuses on tracking changes via the browser’s History API (e.g., pushState and replaceState). Ideal for SPAs using URL path-based routing, ensuring each route change is logged as a new page view.
  • hash: Tracks navigation based on URL hash changes (e.g., #/route). This is suitable for older SPAs or those relying on hash-based routing, capturing shifts in the fragment identifier as virtual page views.
  1. Go to the menu on the top right and navigate to Settings
  2. Click Sites.
  3. Select the desired site.
  4. Select the desired mode in the section Single Page Application (SPA) mode.
  5. Don’t forget to click Save at the bottom of the page.

Client-Side API Functions

Axo Analytics provides a robust set of client-side API functions accessible via the window.axoanalytics object, allowing you to manually trigger tracking events beyond automatic configurations. These functions are essential for custom implementations, such as in SPAs without auto-tracking or for capturing specific user interactions like events, downloads, and outbound links. All functions are asynchronous and non-blocking to maintain smooth user experience.

Track a Pageview

To manually record a page view (when auto-start is disabled), call window.axoanalytics.trackPageview(). This function captures the current page’s URL, title, referrer and many other available metrics.

Track an Event

For logging custom user actions, use window.axoanalytics.trackEvent(name). The name parameter is a required string identifying the event (e.g., button_click or form_submission). You can also add a value parameter: window.axoanalytics.trackEvent(name, value).The value must be a string; it appears verbatim in raw data exports for detailed analysis. If the value represents a numeric quantity (e.g., order amounts or purchase total), it will be automatically aggregated in the dashboard, such as summing totals for metrics like revenue. For currency, input values in cents (e.g., “1900” for $19) to avoid floating-point issues and enable precise calculations.

Track a Download

To manually track file downloads, invoke window.axoanalytics.trackDownload(filename). The filename parameter is a required string specifying the downloaded file’s name or path (e.g., report.pdf). For manually capturing clicks on links leading outside your domain, use window.axoanalytics.trackOutboundLink(url). The url parameter is a required string representing the target external URL (e.g., https://example.com).