# Web analytics

First-party visitors and revenue for one app, plus the older listing report
that still reads a linked GA4 property.

## First-party (Web analytics)

Open **Web analytics** in the sidebar. The page is visitors beside revenue:
conversion, revenue per visitor, bounce rate, average session time, and who is
on the site now. Click a breakdown row to keep only that source, page, or
place. The arrows step the current window backward and forward. Pin a range
when you want it back later.

Revenue is the payments you post (Stripe Checkout handoff, the payments API,
or a `payment` event), minus refunds. A customer who never paid is not treated
as churned. Billing charges that never come through one of those paths stay on
the revenue pages; this page does not invent a match for them.

### Install the snippet

On **Setup**, copy the stack you use:

- **Browser SDK** — paste `/sdk.js` on every page. Page views, route changes,
  engaged time, outbound clicks, and `data-corex-goal` goals are recorded by
  the same snippet that already sends usage events. There is no second tracker.
- **Shopify theme app embed** — the same script in the theme embed, turned on
  in the theme editor.
- **Google Tag Manager** — a custom HTML tag on all pages.
- **Next.js** — load `/cx/sdk.js` and rewrite `/cx` to your CoreX host.
- **Cloudflare proxy** — serve `/cx/*` from your own hostname so the script is
  first-party.
- **Stripe Checkout handoff** — put `visitor_id` and `session_id` on the
  Checkout metadata (or call `CoreX.checkoutUrl` before redirecting) and add
  `?payment_id=` on the success URL. That return only attaches the visitor to
  a payment you already posted. It does not set the amount. A Shopify install
  link gets the same `cx_vid`, `cx_sid`, and `ref` query.
- **Copy AI install prompt** — paste it to an assistant working in the project.

Add `?corex_ignore=1` once in your own browser. That sets a cookie so your
visits are dropped. You can also list office addresses under Settings.

Server-side goals and payments (Paddle, Lemon Squeezy, or anything else) use
the same API token as usage events:

```
POST /api/goals     { "name": "signup", "visitorId": "…" }
POST /api/payments  { "paymentId": "…", "amountCents": 4900, "refundedCents": 0, "visitorId": "…" }
```

`paymentId` is required. Posting the same id again updates that payment and
returns 200. `customerId` is a shop domain, a Shopify shop id, or this app's
customer id — the same lookup as a usage event. A browser `CoreX.payment()`
call does not write revenue.

The same paths exist under `/api/v1`. Name the app when the token is not
already scoped to one. The ignored-address list is one IP or one CIDR range
per line (`203.0.113.9` or `203.0.113.0/24`), not a text prefix.

### Privacy

Cookieless mode replaces the visitor id with a daily hash of a salt, the date,
the address, and the browser. The same person is a new visitor the next day.
Counts stay useful; journeys get shorter. The Settings card says this before
you turn it on.

Set a cookie domain (`.example.com`) to follow a visitor across subdomains.
List every hostname that should count, including a sister domain, under
allowed hostnames. Leave that list empty to accept every site that has the
snippet.

### Share, import, alerts

A share link is a read-only page at `/w/{token}`. The token is shown once and
is not indexed. Import a Google Analytics or Plausible spreadsheet (a date
column and a visitors column) to fill days from before the snippet. Traffic
drops and source spikes are rules on the existing revenue alerts, not a
second alert product.

The customer page shows the same visit as a journey and links to the replay.
Funnels stay in listing analytics; first-party event names that have actually
arrived are added to that builder.

## Listing analytics (GA4)

## What you see
**Listing Analytics** (per app) reports sessions, visitors, traffic sources and
listing conversion from the **GA4 property** you link to that app, plus a live
"on the listing right now" count and a pageview → install funnel.

Link the property once under the app's settings; CoreX caches each report per app
and range, and **Refresh** forces a re-pull when you need it now.

## Use it
- Compare source-level sessions against installs to find the channel that
  converts rather than the one with the most traffic.
- Read it beside [Keywords](../acquisition/keywords.md): rank moves show up in
  sessions before they show up in installs.

## Why it matters
One acquisition view — web traffic and App Store outcome — beats flipping between
GA and CoreX and eyeballing the join.

## Related
- [Page view analytics](page-view-analytics.md) · [Traffic sources](../acquisition/traffic-sources.md)
