See ../README.md for direct VPS installation. Document root for this application is public/.

## Signed server-side conversion events (Build 02)

To record a conversion from a trusted booking or CRM backend, open the website details in an owner or admin workspace and retrieve the private domain signing key. Never expose it to browsers or tag managers. The public domain key remains a separate non-secret identifier.

With prior measurement consent, the landing page can ask `window.copyslice.attributionTokens()` for its active, exposed experiment tokens and include those fields in an authorized form submission to your own backend. For example, the backend can retain `domain_key`, `experiment_id`, and `visitor_id` with the lead. This API returns an empty array without consent.

When a qualifying lead event is confirmed on the backend, POST JSON to `/api/server-conversions`:

```json
{"domain_key":"32-character-lowercase-hex","experiment_id":1,"visitor_id":"32-character-lowercase-hex","event_id":"unique-stable-16-to-64-character-ID","goal_name":"lead_submitted"}
```

Use a 10- or 11-digit Unix timestamp in `X-CS-Timestamp` and `X-CS-Signature`, computed with HMAC-SHA256 over `TIMESTAMP + '.' + EXACT_JSON_BODY`. Decode the 64-character hexadecimal domain signing key into its binary 32-byte key before computing the HMAC. Signatures outside five minutes are rejected. Re-use the same stable `event_id` for retry attempts, and do not change its assignment or goal. Conversions after pause are accepted while the prior assignment remains inside its original attribution window. Do not send the event before an actual exposure has been recorded by the server.

The example `examples/send_server_conversion.php` reads its secret from `CS_SERVER_SIGNING_KEY` and endpoint from `CS_CONVERSION_ENDPOINT`. Use your own private infrastructure to call it; the demo script is not a public browser API. The signed endpoint is additive to the existing browser event endpoint, which still needs independent bot defenses and rate limits before a production launch.

Full isolated MySQL testing instructions are in `../deploy/test/README.md`.
