The Vemetric JavaScript SDK provides automatic pageview tracking and a simple API for tracking custom events in browser-based applications.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vemetric/vemetric/llms.txt
Use this file to discover all available pages before exploring further.
Installation
The JavaScript SDK is loaded via a script tag and doesn’t require npm installation. For React applications, see the React SDK documentation.
Script Installation
Add the Vemetric script to your HTML<head> section:
src and data-host URLs with your own domain.
Configuration Options
Configure the script using data attributes:Your project token from the Vemetric dashboard (required)
The URL of your Vemetric hub instance (e.g.,
https://hub.vemetric.com)Whether to allow cookies for user tracking. Set to
"false" for cookieless tracking.Comma-separated list of URL patterns to mask in analyticsExample:
"/admin/*,/settings,/user/*/private"Basic Usage
Automatic Pageview Tracking
Pageviews are tracked automatically once the script is loaded. No additional code is required.Manual Event Tracking
Track custom events using the globalvemetric object:
Event with Custom Data
Attach custom properties to your events:User Identification
Identify Users
Identify authenticated users to track them across sessions:Unique identifier for the user (e.g., user ID, email)
Display name for the user
URL to the user’s avatar image
Set User Properties
Update user properties alongside identification:Reset User Identity
Clear the current user identity (useful for logout):Advanced Usage
Track Events with User Data
Combine event tracking with user property updates:User Data Operations
- Set Properties
- Set Once
- Unset Properties
Set or update user properties:
Outbound Link Tracking
Outbound links are tracked automatically when users click links to external domains.API Reference
vemetric.trackEvent(name, options?)
Track a custom event.
Name of the event to track
Optional configuration object
vemetric.identify(options)
Identify a user and optionally update their properties.
vemetric.resetUser()
Reset the current user identity. Call this when users log out.
Privacy & Compliance
Cookieless Tracking
Disable cookies for privacy-focused tracking:Path Masking
Mask sensitive URLs from being tracked:Examples
E-commerce Tracking
SaaS Application Tracking
Next Steps
React SDK
Use Vemetric in React applications
Tracking Events
Learn event tracking best practices
Configuration
Advanced configuration options
Node.js SDK
Server-side tracking with Node.js