Tracking script
The browser script records an initial page view, reports active engagement, and exposes methods for manual page views and custom events.
Script tag
<script defer src="https://gumanalytics.com/js/analytics.js?v=be9add48f624" data-domain="example.com"></script>The data-domain attribute is required and must match a domain in Gumanalytics. The default tracking endpoint is https://gumanalytics.com/api/watch. You may set data-endpoint only when using another compatible endpoint intentionally.
Page views and engagement
When the script loads, it records the current path and query string as a page view. While the page is visible, it also records active engagement, including when visibility changes or the visitor leaves the page.
window.gum.page();Call window.gum.page() after a client-side route change in a single-page application. Do not call it for normal full-page navigations because the initial page view is already sent.
Custom events
window.gum.track("newsletter_signup", { location: "footer" });The event name must be a non-empty string. Properties are optional and should not contain sensitive personal information.
Identify a known user
window.gum.setSessionName("John");
window.gum.setTrackingId(currentUser.id);The session name becomes the display name for linked visits. Use a stable internal tracking ID to connect the same user across devices. Gumanalytics hashes the tracking ID for the selected project before storing it.
Optional replay and heatmap capture
<script defer src="https://gumanalytics.com/js/analytics.js?v=be9add48f624" data-domain="example.com" data-session-replay="true" data-replay-sample-rate="100" data-heatmap="true" data-heatmap-sample-rate="100"></script>Enable replay and heatmaps in project Settings before using their generated attributes. Sampling rates control the percentage of eligible visits captured for each feature.