Insights Script

The Insights script is the easiest way to measure user activity in your browser applications. Once Insights is enabled, you can copy the script URL from the Insights settings page.

Including the script

Once you have the URL at hand, you can include the script in your application by adding the following snippet to your HTML:

<script src="script-url-here" async></script>

Initializing the script

Once the script is loaded, you can call the init function to initialize the script.

  environmentId: "environment-id-here",

Tracking user activity

While the Insights script automatically tracks page views, you may want to add additional events to track user activity. You can do this by calling the push function.

  category: "category-here",
  kind: "kind-here",


Once loaded, the insights property is attached to the global window object.

declare global {
  interface Window {
    insights?: {
      init: (config: { environmentId: string }) => void;
      identify: (userIdentityId: string) => void;
      push: (event: { category: string; kind: string }) => void;


The init function initializes the Insights script. It must be called before any other functions.


The identify function links the current Insights user to a User Management user identity. This allows you to identify users across devices and browsers.


The push function pushes an event to the Anzu Insights API. The event will be associated with the current Insights user and session.