Updated version of googleAnalitics script to track users in ServiceNow native UI
✓ Published0🌍 Public
Aandrew-psch
Last edited Oct 26, 2018
Created on Oct 26, 2018
This example tracks user activity in ServiceNow’s native UI by sending Google Analytics pageviews whenever the parent page’s title changes. The code uses the Google Analytics tracking snippet (`ga('create', …)` and `ga('send', …)`) and a `MutationObserver` to watch the `window.top.document.querySelector("title")` element for attribute, character data, or child list changes. On each mutation, it fires a pageview hit with the updated title and current `location.href`. The approach relies on the browser’s native MutationObserver API rather than a custom event system.
AI-generated description