Janus Client SDK
A lightweight JavaScript library for tracking events from web applications. Automatically handles batching, retries, rate limiting, and persistence.
Lightweight (~3KB)Auto RetryBatchingPersistence
Automatic Page Tracking
Default Behavior#
By default, Janus automatically tracks page views when the SDK initializes. No manual Janus.page() calls are needed for basic page view tracking.
javascript
// This automatically tracks a page viewJanus.init('jns_your_api_key_here');// The above is equivalent to:// Janus.init('jns_your_api_key_here');// Janus.page();
SPA Navigation Support#
For Single Page Applications (React, Vue, etc.), Janus monitors the History API to automatically track route changes. This includes pushState, replaceState, and browser back/forward navigation.
javascript
// SPA navigation is tracked automatically// When your router calls history.pushState(), a page view is recorded// React Router, Vue Router, and similar libraries// all trigger page views automatically
Disabling Auto-Tracking#
If you need full control over page view tracking, you can disable automatic tracking:
javascript
// Disable all automatic page view trackingJanus.init('jns_your_api_key_here', {trackPageViews: false, // No page view on inittrackSPANavigation: false // No SPA route change tracking});// Now track pages manually where neededJanus.page('Dashboard');
Partial Auto-Tracking#
You can mix automatic and manual tracking. For example, disable only the initial page view but keep SPA tracking:
javascript
// Disable initial page view, but keep SPA trackingJanus.init('jns_your_api_key_here', {trackPageViews: false, // Skip initial page viewtrackSPANavigation: true // Still track SPA navigation (default)});// Manually track after some setup is completeif (userIsReady) {Janus.page('Home');}
Need Help?
If you have questions or run into issues, check out our troubleshooting guide or reach out to our support team.
Troubleshooting Guide