Skip to main content

Prerequisites

Before you begin, ensure you have:

Step 1: Set Up Web Insights (For Web Applications)

If you want to generate web insights from your website, start by adding the InfiniteWatch script to your HTML pages.

Add the Script Tag

Add the following script tag to your HTML pages (typically in the <head> or before the closing </body> tag):
<script async
  src="https://app.infinitewatch.ai/watch.js"
  data-iw-organization-id="YOUR_ORGANIZATION_ID">
</script>
Replace YOUR_ORGANIZATION_ID with your actual organization ID. You can find this in your InfiniteWatch dashboard or contact [email protected] to get your organization ID.

How It Works

Once the script is added, InfiniteWatch will automatically:
  • Record user sessions and interactions
  • Capture DOM events, mouse movements, and clicks
  • Generate web insights data
  • Send insights to your InfiniteWatch dashboard
The script loads asynchronously, so it won’t block your page load. It automatically starts recording when the page loads.

Step 2: Identify Your Users

After the tracker is initialized and recording has started, you can associate sessions with specific users in your system using the identify() method. This links session recordings and analytics to individual users.

Basic Usage

InfiniteWatch.identify({
  external_id: 'user-12345'
});

With Additional User Information

InfiniteWatch.identify({
  external_id: 'user-12345',
  email: '[email protected]',
  full_name: 'John Doe',
  metadata: {
    plan: 'premium',
    signup_date: '2024-01-15'
  }
});

In a Login Flow

async function handleLogin(user) {
  // Identify the logged-in user
  InfiniteWatch.identify({
    external_id: user.id,
    email: user.email,
    full_name: user.name
  });
}

What It Does

When you call identify():
  1. Links Sessions to Users: Associates the current session with your system’s user identifier
  2. Persists Identity: The external_id is stored in a cookie (2-year expiration) and persists across page reloads and sessions
  3. Auto-Collects Metadata: Automatically gathers browser information (user agent, language, screen dimensions, timezone, etc.)
  4. Enriches Events: All subsequent events will include the external_id in their payloads
Required Field: The external_id is required - use a stable identifier from your system (like a database user ID). Optional fields include email, full_name, and custom metadata.
Privacy: Only the external_id is persisted in cookies. Email, full name, and metadata are sent to the API but not stored in browser cookies.

Best Practices

  • Call Early: Identify users as soon as they’re authenticated to ensure all session data is linked
  • Use Stable IDs: Use consistent identifiers (database IDs) rather than temporary values
  • Update Anytime: You can call identify() multiple times to update user information
For complete documentation on the identify() method, including all parameters, error handling, and advanced usage, see the full identify() documentation.