# Prelumen Analytics setup

You are an AI coding agent. Follow these steps to add Prelumen Analytics to this project and confirm it works.

## 1. Connect the MCP server

Skip this step if a Prelumen MCP server is already connected. Otherwise ask the user for a Prelumen API key. Keys are created at https://hub.prelumen.com/users/organisations under the organisation's API keys. Never commit the key.

    claude mcp add --transport http oneco https://analytics.prelumen.com/mcp --header "X-API-Key: <key>"

Other clients: same URL, same header.

## 2. Find or register the website

Call `create_website` with the site's URL. It returns the website if an organisation of this key already has it, and registers it otherwise. If the response asks for `organisation_uuid`, ask the user which organisation to use.

## 3. Add the snippet

Put `tracking_script.snippet` from that response into the `<head>` of every page, in the shared layout.

`data-persist` lets the script set the first-party cookie `oneco_persist_id` when Persist Mode is enabled for the website. To gate that cookie on consent, render the attribute only after the visitor has consented. Cookieless analytics work either way.

## 4. Deploy and verify

Deploy. Call `verify_installation` with the `website_uuid` and keep `checked_at`. Then open a page of the site in a browser and call `verify_installation` again. Tracking works when `last_hit_at` is equal to or later than the `checked_at` you kept; both are server times in UTC with second precision. If it is not, wait a few seconds and call again. If it stays earlier, check that the deployed page contains the snippet and runs on one of `allowed_hostnames`; hits from other hosts are rejected. Tell the user the result.
