Analytics Script

The Analytics script is the easiest way to measure user activity in your browser applications. Once Analytics is enabled, you can copy the script URL from the Analytics 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 Analytics 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 analytics property is attached to the global window object.

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


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


The identify function links the current Analytics 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 Analytics API. The event will be associated with the current Analytics user and session.