Overview
The AutoTrackPlugin automatically tracks common events based on DOM elements and user interactions, reducing manual tracking code.Installation
Options
boolean
default:"false"
Automatically track page view events on navigation.
ClickConfig
Configuration for automatic click tracking.
ViewabilityConfig
Configuration for automatic viewability tracking.
Click Tracking
Automatically track clicks on product elements:Click Config Options
string
required
CSS selector for clickable product elements.
(el: Element) => string
required
Function to extract the product ID from a clicked element.
(el: Element) => number
Function to extract the position from a clicked element. Defaults to 0.
HTML Setup for Click Tracking
Viewability Tracking
Automatically track when products become visible:Viewability Config Options
boolean
default:"false"
Enable automatic viewability tracking.
string
CSS selector for viewable elements. Defaults to clicks.selector.
number
default:"0.5"
Percentage of element that must be visible (0.0 to 1.0).
number
default:"1000"
Milliseconds element must be visible before tracking.
(el: Element) => string
Function to extract product ID. Defaults to clicks.extractItemId.
(el: Element) => number
Function to extract position. Defaults to clicks.extractPosition.
Page View Tracking
Track page views automatically:- Initial page load
- SPA navigation (using History API)
- Hash changes
Complete Configuration
HTML Data Attributes
The plugin expects specific data attributes on your product elements:Required Attributes
Optional Attributes
Dynamic Content
For dynamically loaded content, the plugin uses MutationObserver to detect new elements:Combining with Manual Tracking
You can use AutoTrackPlugin alongside manual tracking:Framework Integration
React
Vue
Debugging Auto-Track
Combine with DebugPlugin to see what’s being tracked:Next Steps
Debug Plugin
Development tools
Consent Plugin
Privacy compliance