# Measure visits and inquiries

The starter sends no analytics events by default. Choose a measurement account and owner before enabling collection. Separate browsing, contact intent and provider acceptance.

| Event | Trigger | Safe reporting fields |
| --- | --- | --- |
| page_view | One rendered page load | Canonical path and page type |
| contact_click | Visitor activates phone or email link | Channel and source path |
| form_start | First interaction with an enabled form | Form name and source path |
| generate_lead | Provider accepts one valid inquiry | Form name and an opaque deduplication key kept server-side |

## Connect a measurement provider

1. For GA4, create a web data stream for the production domain. Record its public measurement ID. Keep any Measurement Protocol secret in the backend environment.
2. Choose one page-view mechanism. If automatic page views are enabled, skip a second manual page_view. Review enhanced measurement form events for overlap with custom events.
3. Add the selected tag only after reviewing consent, privacy copy and the provider's required script and connection origins. The starter blocks browser scripts by default. Update public/_headers and its tests for the approved integration; do not disable the policy. Apply consent choices before loading tags where required.
4. Use the provider's verified success webhook or your server's accepted-submission branch to emit a lead. Deduplicate provider retries using the submission identifier. A static form that navigates to a hosted provider cannot verify acceptance from its submit button. If the provider offers no verified success signal, report form starts and count accepted inquiries in its dashboard.
5. Exclude names, emails, phone numbers, message bodies, full referrers and arbitrary query strings from analytics. Use a separate test stream or exclude staging traffic.
6. In the provider's debug view inspect one page load, one abandoned form, one rejected submission and one accepted test submission. Expected lead counts are respectively zero, zero, zero and one. Replaying a success webhook must leave the accepted count at one. Check actual inbox delivery separately.

Prompt: Map the existing form lifecycle before adding analytics. Identify the authoritative success signal, show the events and allowed fields, and explain how you will verify that failed inquiries never count as leads.

References: https://developers.google.com/analytics/devguides/collection/ga4/reference/events and https://developers.google.com/analytics/devguides/collection/protocol/ga4

## Use this with Codex

> Read skills/audit-astro-leads/SKILL.md. Audit the form events and lead record. Show what distinguishes observed ChatGPT referrals, self-reported discovery and unknown sources.
