> ## Documentation Index
> Fetch the complete documentation index at: https://vida.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Reseller Application Telemetry

> Connect an eligible reseller or partner Vida application to an analytics provider using lifecycle scripts.

Eligible reseller and partner accounts can run telemetry scripts in their Vida application. Use
these hooks to connect a browser analytics provider and measure application usage under your own
analytics account.

<Warning>
  Telemetry scripts execute in the browser. Never place secret API keys, private credentials, or
  privileged backend operations in them. Test every script in a non-production reseller before
  enabling it for customers.
</Warning>

## Available lifecycle scripts

| Script                         | When it runs                                                            | Inputs           |
| ------------------------------ | ----------------------------------------------------------------------- | ---------------- |
| **Base Script**                | As the application renders. Use it to load the provider library.        | None             |
| **App Initialization Script**  | When the application initializes, including before a user is available. | None             |
| **User Identification Script** | When Vida identifies the signed-in user and routed account.             | `id`, `traits`   |
| **Page View Tracking Script**  | On a Vida page view.                                                    | `page`, `props`  |
| **Event Tracking Script**      | When Vida emits a tracked application event.                            | `event`, `props` |

The editor checks whether the supplied text is valid JavaScript, but syntax validation does not
prove that a provider loaded, an event was delivered, or the script is safe.

## Recommended setup

1. Create a test source or project in your analytics provider.
2. Add the provider's browser loader to **Base Script**.
3. Initialize anonymous application tracking in **App Initialization Script** when required.
4. Map `id` and the supplied `traits` in **User Identification Script**.
5. Send Vida `page` and `props` values from **Page View Tracking Script**.
6. Send Vida `event` and `props` values from **Event Tracking Script**.
7. Use the provider's live debugger to verify identification, page views, and representative events.
8. Repeat the validation from a downstream customer account before copying the configuration to
   production.

Example provider-neutral hooks:

```javascript theme={null}
// User Identification Script
window.analytics?.identify(String(id), traits);
```

```javascript theme={null}
// Page View Tracking Script
window.analytics?.page(page, props);
```

```javascript theme={null}
// Event Tracking Script
window.analytics?.track(event, props);
```

## Use traits carefully

The `traits` object describes the signed-in user and the routed Vida account. Use stable external
identifiers when you need to reconcile Vida activity with your product. Inspect the actual payload
in the test environment instead of assuming every account type exposes the same fields.

Collect only the data your analytics implementation requires and apply your privacy, consent,
retention, and access policies.

## Change scripts safely

Keep a copy of the working production scripts before replacing them. Change one lifecycle hook at a
time, verify it in the provider, and watch for page errors or duplicate events. Remove a script by
clearing that field only after confirming no other hook depends on its global library.
