Guides
Content analytics
See what your visitors actually see. Val counts pages, and also the content on them: which headings, images and sections were on the page, and which were on screen.
Use it for
- Finding which sections of a page people actually look at
- Comparing a page before and after a publish
- Seeing views beside the content, in the Studio
Content, not just pages
Most analytics tools count page views. Val also knows which piece of content each element on the page shows -- the same thing the Studio uses for visual editing -- so it counts the content too, with nothing to tag by hand:
Rendered: the content was on the page.
Viewed: it was on screen, at least half of it for at least a second.
Page views per route, and where visitors came from (the referring site and campaign), their country, device, browser and operating system.
Each page view is tied to the content version it was rendered from, so you can compare a page before and after a publish. In the Studio, the numbers show beside the content being edited.
Private by design
No cookies, no storage and no visitor IDs: Val keeps counts, never people, so there are no unique visitors. The IP address is never read. Nothing is counted in draft mode, in the Studio, from an editor browsing with Val enabled, or from an automated browser.
Turn it on
On a site Val hosts, analytics is off until the project's owner turns it on, in the project's settings under Analytics. The site needs no code and no rebuild for it: Val hands the setting to the site, and switching it off stops the counting straight away.
Optional: decide in the code
With no analytics prop, ValProvider reads the setting itself. To decide in the code instead, pass it from the site layout's loader. fetchValAnalytics is exported by the val.server.ts Val writes for a hosted project, and what is passed wins.
Locally
To see it working while you develop, set it in .env.development. Only the development server reads it, so it can't follow your code to production.
On your own hosting
A site on your own hosting is counted on the Pro plan. Its own Val server answers /api/val/analytics and forwards each count to Val with the VAL_API_KEY it already has for publishing. Turn analytics on in the project's settings on val.build, and pass the setting from the layout, read on the server so it is never baked into the browser bundle:
Then set VAL_ANALYTICS=true where the site is deployed. The visitor's country comes from your host's own header where it sends one (Vercel, Cloudflare or CloudFront).
Price
Content analytics is an extra on a Hosted project, or a Pro project on your own hosting, priced by a tier of page views a month: from $19 for 100,000 to $169 for 10 million. Over your tier nothing is charged that you did not pick, counting never stops and your site is never touched. See Pricing for every tier.
Caveats
TanStack Start only, for now. Next.js support comes later.
Content read with Val's hooks (useVal, useValRoute) is counted. Content read in a loader or a server function is not, just as it can't be clicked to edit.
Text that leaves React keeps Val's invisible edit tags: JSON-LD, the page title, a share link built with encodeURIComponent. Wrap the value in val.raw() where it leaves React. In development, Val warns in the console about each place it finds one.
A component that reads content renders once more right after hydration, as it already does for an editor. The HTML the server sends is the same with analytics on or off.