Skip to main content

Overview

The CustomerOS website tracker allows you to monitor visitor behavior and identify users across your website. Once installed, it automatically tracks page views and custom events, providing valuable insights into how visitors interact with your site.

Installation

To install the CustomerOS tracker, follow the instructions in the app with your specific reverse-proxied domain. Choose between the HTML script or JavaScript snippet depending on the application you are using.

Identifying Users

Once the tracker script is loaded, you can identify users and attach custom properties to their profile using the identify function.

Basic Usage

window.cos.identify({
    email: "user@example.com",
    name: "John Doe",
});

When to Use Identify

Call the identify function at key moments in your user journey:
  • After user login: Identify the user with their profile information
  • After signup: Capture new user details
  • On profile updates: Update user properties when they change
  • On page load (for authenticated users): Ensure returning users are identified

Example: Identify on Login

// After successful login
async function handleLogin(email, password) {
    const user = await loginUser(email, password);

    // Identify the user in CustomerOS
    window.cos.identify({
        email: user.email,
        name: user.name,
        user_id: user.id,
        plan: user.subscription.plan,
    });
}

Disabling Automatic Event Tracking

By default, the tracker automatically captures page views and events. If you want to disable automatic event tracking and only track events manually, set the c.__disableCosEvents__ parameter to true. This is especially helpful for preventing unwanted collection of data within applications where PII and other data may be sent and received.
<script id="customeros-metrics" type="text/javascript">
    (function (c, u, s, t, o, m, e, r, O, S) {
        var customerOS = document.createElement(s);
        customerOS.src = u;
        customerOS.async = true;
        c.__disableCosEvents__ = t;
        (document.body || document.head).appendChild(customerOS);
    })(
        window,
        "https://reverse-proxy.example.com/analytics-0.1.js",
        "script",
        true
    );
</script>

Platform-Specific Guides

For specific implementation instructions for your platform, see the guides below:

Troubleshooting

Having issues with the tracker? Check out our troubleshooting guide for common solutions.
I