Product analytics

Web analytics and attribution

Pageviews, sessions, bounce rate, entry and exit pages, referrers, UTM campaigns, channels with first- and last-touch attribution, ad click ids, web vitals, heatmaps, and how internal and bot traffic is kept out.

Markdown

Web analytics answers the questions a site owner asks first: how many people came, which pages they read, where they came from, and which of those visits turned into something that matters. In AppHelm it is built from the browser SDK's own first-party events. There is no separate script or tag to add.

Open Web in the app and pick a product. The report covers the last 7, 30 or 90 days.

#What the browser SDK records

Once the visitor has given analytics consent, the SDK records these events by itself. You don't call anything.

Event When What it carries
page_viewed On start, and on every pushState, replaceState or back/forward that changes the path path, referrer, title, utm_source, utm_medium, utm_campaign, the session id and the visitor's hashed id
$pageleave When the tab is hidden for good (pagehide) path, time on the page (duration_ms, at most one hour) and the deepest scroll point (scroll_pct)
$web_vitals With $pageleave lcp_ms, inp_ms and cls for the page load, when the browser measured them
$autocapture Clicks, form submits and changes The element's tag, a hash of its structural selector and where on the page it was clicked. Never input values or element text
$rageclick Three clicks on the same element within one second As $autocapture
$dead_click A click on something that isn't a link, button or form control, followed by no DOM change or navigation within 0.7 s As $autocapture

All of these are autocapture: autocapture: false in the options, or turning autocapture off for the product in Settings → Capture, stops them, pageviews included. Events and autocapture lists everything autocapture records and never records.

When AppHelm receives a pageview from a browser, it also derives coarse labels from the request: device type, browser, operating system and country. The user agent and IP address themselves are never stored.

#Turn it on

The browser SDK sends nothing until the visitor gives analytics consent. Call setConsent from your consent banner, or pass consent when you create the client if you already know the answer.

No example for this step; showing JavaScript (browser).

// From your consent banner
analytics.setConsent({ analytics: true, replay: false });
import { useApphelm } from "@sansavision/apphelm/react";

function CookieBanner() {
  const apphelm = useApphelm(); // null while server rendering
  return <button onClick={() => apphelm?.setConsent({ analytics: true, replay: false })}>Accept</button>;
}
app/cookie-banner.tsx
"use client";
import { useApphelm } from "@sansavision/apphelm/react";

export function CookieBanner() {
  const apphelm = useApphelm();
  return <button onClick={() => apphelm?.setConsent({ analytics: true, replay: false })}>Accept</button>;
}
import { useApphelm } from "@sansavision/apphelm/vue";

const apphelm = useApphelm(); // null while server rendering
const accept = () => apphelm?.setConsent({ analytics: true, replay: false });
// `apphelm` is the client createBrowserSdk() returned in src/lib/apphelm.ts
apphelm.setConsent({ analytics: true, replay: false });

The first pageview is recorded the moment consent arrives, so a visitor who accepts on the landing page is still counted from that page, with its referrer and UTM tags.

#Pageviews

#Single-page apps

Nothing extra is needed for client-side routing. The SDK watches history.pushState, history.replaceState and the back and forward buttons, and records a pageview whenever the path changes. A change to the query string or the #hash alone is not a new pageview, so apps that route with #/page URLs need manual pageviews (below).

The framework helpers have router integrations as well, and they are off by default when autocapture is on, so you never get two pageviews for one navigation. Turn them on only if you set autocapture: false:

No example for this step; showing Next.js.

app/apphelm-provider.tsx
"use client";
import { ApphelmNextProvider } from "@sansavision/apphelm/next";

export function AppHelm({ children }: { children: React.ReactNode }) {
  return (
    <ApphelmNextProvider
      options={{ key: process.env.NEXT_PUBLIC_APPHELM_KEY!, workspaceId: "org_…", productId: "prd_…", autocapture: false }}
      pageviews // one pageview per App Router path change
    >
      {children}
    </ApphelmNextProvider>
  );
}
src/main.ts
import { apphelm } from "@sansavision/apphelm/vue";

app.use(apphelm, {
  options: { key: import.meta.env.VITE_APPHELM_KEY, workspaceId: "org_…", productId: "prd_…", autocapture: false },
  router, // vue-router: one pageview per navigation that changes the path, with route_name
  pageviews: true,
});
src/routes/+layout.svelte
import { afterNavigate } from "$app/navigation";
import { trackPageviews } from "@sansavision/apphelm/svelte";

// `apphelm` is what createApphelm() returned; sends the route id (/blog/[slug]) as `route`.
trackPageviews(afterNavigate, apphelm, { pageviews: true });

With React Router or any other client router, the core's history tracking already covers you. If you turn autocapture off, call page() after each navigation yourself.

Angular's provideApphelm({ options, router: Router, pageviews: true }) does the same on each NavigationEnd.

#Manual pageviews

page() records a page_viewed with the current path, referrer, title and UTM tags. Extra properties are added to it.

No example for this step; showing JavaScript (browser).

analytics.page({ section: "pricing" });
const apphelm = useApphelm();
apphelm?.page({ section: "pricing" });
useApphelm()?.page({ section: "pricing" });
apphelm.page({ section: "pricing" });

A manual pageview is not autocapture: the product's autocapture switch, sampling and blocked paths don't apply to it.

#Pages that are never recorded automatically

Automatic pageviews and clicks are never recorded on sign-in, sign-up, billing, payment and admin pages: any path that is, or starts with, /auth, /sign-in, /sign-up, /login, /logout, /billing, /checkout, /payment, /admin or /account/security. You can add more paths per product in Settings → Capture. If you need to count visits to one of these pages, call page() there yourself.

#Pageviews from a server

A server SDK or the HTTP API can send a page_viewed event with a path property. It counts in views and top pages. It has no browser session, so it is left out of sessions, bounce rate, entry and exit pages and channels, and it has no device, browser, OS or country.

No example for this step; showing HTTP (curl).

curl -X POST https://apphelm.dev/api/v1/events \
  -H "Authorization: Bearer $APPHELM_API_KEY" -H "Content-Type: application/json" \
  --data '{"workspaceId":"org_…","productId":"prd_…","eventName":"page_viewed","properties":{"distinct_id":"user-123","path":"/pricing"}}'

Prefer the browser SDK for web analytics whenever the page runs JavaScript.

#Visitors, sessions and bounce rate

Figure How it is counted
Views Every page_viewed (and $pageview, from PostHog-compatible sources), plus mobile screen views of the product
Visitors Distinct browser ids with a view in the window. One id per browser once consent is given, so one person on two devices, or after clearing site data, counts twice
Sessions Distinct browser tab sessions with a view. A session is one browser tab: it survives reloads in that tab and ends when the tab closes or reset() is called. There is no 30-minute inactivity timeout
Bounce rate The share of measured sessions with exactly one view, no autocaptured click or submit, and under 10 seconds from first to last event
Average session First to last event of each measured session, capped at 4 hours

A session is measured when its end was seen, that is, when a $pageleave arrived. Sessions without one (a browser that crashed, autocapture off) count in Sessions but not in bounce rate or duration.

Times are bucketed by when AppHelm received the event, in UTC.

#Pages, entry and exit pages

  • Top pages: the 25 paths with the most views.
  • Entry pages: the first view of each session, by the browser's own clock. The top 10 are shown.
  • Exit pages: the last view of each session. A session that only saw one path enters and exits there.

Paths are stored without the query string or fragment. The title property is sent but isn't a column of the report.

#Referrers and UTM tags

The SDK sends document.referrer and the utm_source, utm_medium and utm_campaign parameters of the page URL with each pageview.

  • A referrer is stored as its origin and path only. Its query string and fragment, which often hold other sites' search terms and tokens, are dropped on arrival.
  • The report lists the 15 most frequent referrers (no referrer shows as (direct)) and the 15 most frequent UTM sources ((none) when untagged).
  • utm_content and utm_term are not part of web analytics. They are kept only in ad click evidence, with ads consent (see Ad click ids).

Tag every link you control, especially in emails, ads and social posts: ?utm_source=newsletter&utm_medium=email&utm_campaign=spring-sale.

#Channels

Each session start is sorted into one channel. The rules run in this order and the first match wins; UTM tags win over the referrer.

Channel When
Direct No UTM tags, and no referrer, or a referrer that is the site itself, a sign-in provider or a payment page
Paid search utm_medium is paid (cpc, ppc, paid…, anything containing cp, retargeting) and the source or referrer is a search engine
Paid social utm_medium is paid and the source or referrer is a social network
Display utm_medium is display, banner, expandable, interstitial or cpm
Paid other utm_medium is paid and the source is neither a search engine nor a social network
Email utm_source or utm_medium is email, e-mail, e_mail or newsletter, or the referrer is a webmail site
SMS utm_source or utm_medium is sms
Affiliate utm_medium is affiliate, affiliates or partner
Organic search utm_medium is organic, or the source or referrer is a search engine
Organic social utm_medium is social, social-network, social-media or sm, or the source or referrer is a social network
Video utm_medium is video, or the source or referrer is a video site (YouTube, Vimeo, Twitch, Dailymotion, Loom)
AI assistant The source or referrer is an AI assistant (ChatGPT, Perplexity, Claude, Gemini, Copilot and others)
Referral utm_medium is referral, link or app, or any other referrer with no UTM tags
Other UTM tags are present but match no rule above

The source of a session is its utm_source when there is one, otherwise the referrer's host without www., otherwise (direct). Sign-in and payment pages a visitor passes through and comes back from (Google and Apple sign-in, Microsoft login, Auth0, Okta, Stripe Checkout, PayPal, Paddle, Lemon Squeezy and others) are not counted as where the visit came from.

www.example.com and app.example.com count as the same site, so moving between them is not a referral. docs.example.com and app.example.com are different sites to AppHelm: a visit from one to the other is a referral.

#First and last touch

A touch is the start of a session: its channel, source, medium, campaign, referrer host and landing page. AppHelm keeps one touch per visitor per session. A later pageview in the same session with different UTM tags (a campaign link opened in a tab already on the site) is a new touch.

  • First touch is a visitor's earliest touch.
  • Last touch is a visitor's latest touch that is not Direct. Direct is the last touch only when the visitor has no other, so a direct return visit never takes the credit from the campaign before it.

The Acquisition section of the report lists channels, campaigns, sources and landing pages with their sessions and visitors. A selector switches conversions between first touch and last touch.

#When a visitor signs in

A visitor is anonymous until your site gives the SDK their user id, with identify or the distinctId option. When a session continues under the signed-in id, the anonymous visitor's touches move to that id, so the person keeps the first touch of the visits that led to the sign-up. This happens only when the earlier id belongs to no identified person, so two signed-in people sharing a browser tab are never merged.

Call reset() when someone signs out. It starts a new anonymous visitor and a new session. Users, people and groups covers identity in full.

#Conversions by channel and campaign

Each channel and campaign line also shows what it led to, credited by the touch model you chose:

Column What is counted
Activated Identified people who first reached an approved customer outcome in the window
New paying accounts Accounts whose first active, paid snapshot (from your server's group calls) falls in the window
MRR Those accounts' latest recurring amount per month, per currency. A yearly amount is divided by 12
  • A conversion is credited to one touch seen at or before it, never to a later one.
  • Only people your server identifies with the same id the browser SDK was given can be joined to a touch. A conversion with no touch before it is shown on its own line as not attributed. It is never shared out over the channels.
  • Amounts are shown per currency, side by side. They are never converted or added up, and they are reported values, not collected revenue.
  • Sessions are counted in the window, but a conversion can be credited to an older touch, so a channel can show conversions next to "no sessions in this window".
  • Multi-touch models, ad spend and incrementality are not part of AppHelm.

#Website visitor outcomes

A marketing site or landing page has no signed-in customers to activate. Its success is a website visitor outcome: a browser event the site already sends, such as cta_click, optionally narrowed by a property. Define one in Settings → Outcomes → Create an outcome, choosing Website visitors (from a browser event), or with the API:

curl -X POST https://apphelm.dev/api/v1/outcomes \
  -H "Authorization: Bearer $APPHELM_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \
  --data '{"subject":"visitor","productId":"prd_…","outcomeKey":"store_click","name":"Store click","description":"A press on a Get it on Google Play button.","match":{"event":"cta_click","where":[{"key":"location","operator":"equals","value":"hero"}]}}'

The key needs the outcomes:write scope. A condition uses equals, not_equals, contains or is_set; the API takes up to three, the form one.

  • The outcome is saved as a draft and counts nothing until an owner or administrator approves it. Once approved, it is counted over the stored history straight away.
  • It can't use AppHelm's own events, autocapture events (they can be sampled) or events stored without their properties ($exception, $web_vitals and others). Use an event you send with track(), or page_viewed with a path condition to count visits to a page.
  • A condition on a property events never keep, such as title or a key named like personal data (email, token), is refused, because it could never match.

For up to three approved visitor outcomes, every acquisition table gains two columns: the visitors credited to the row who reached the outcome, and that number over the row's visitors. Each visitor in the window is credited to one of their touches by the same first- or last-touch rule.

#Ad click ids and ad measurement

Web analytics itself reads only the referrer and the three UTM tags. Ad platforms' click ids are read only when you declare the visitor's ads consent, for ad measurement through Yieldline:

No example for this step; showing JavaScript (browser).

analytics.setConsent({ analytics: true, replay: false, ads: "measurement" });
apphelm?.setConsent({ analytics: true, replay: false, ads: "measurement" });
ads level What it enables
(absent or false) Nothing is read or sent for ads
"measurement" Click ids and campaign tags from the landing URL are kept as evidence, so conversions can be reported to ad platforms
"personalization" The above, plus the visitor's IP address and user agent on the conversion (Meta needs them to match a website conversion)

With ads consent, the SDK reads the landing URL once per page load: gclid, gbraid, wbraid, fbclid, ttclid, msclkid, li_fat_id, rdt_cid, twclid, all five utm_* tags and Yieldline's yl_ad and yl_src, plus Meta's _fbp and _fbc cookies when a Meta pixel set them. It sends them once, with the next event. AppHelm keeps this evidence apart from event properties, for 90 days, and uses it only when it sends a conversion to a connected Yieldline workspace (Settings → Integrations → Yieldline). AppHelm never asks for, infers or blocks on ads consent: declaring it correctly is your responsibility.

The iOS, macOS and Android SDKs collect install evidence the same way (recordInstall, the Play install referrer, the Apple Ads token), with an adsConsent option.

#Web vitals

The report shows the average LCP, INP and CLS over the window's $web_vitals samples. They are measured once per page load and sent when the tab is hidden, so single-page-app navigations share the load's values. INP is the slowest interaction seen on the page, an upper bound of the real INP. Vitals are part of autocapture.

Performance → Web vitals has the full view: p75 per page, ratings against web.dev's thresholds, FCP and TTFB from traced page loads, and alerts. See Tracing and performance.

#Heatmaps and scroll depth

Heatmaps shows where people click on one path over the last 1 to 90 days (14 by default), from autocaptured clicks. Clicks are counted in a 40 × 24 grid of the viewport, so the map is aggregate counts, never a screenshot of the page. End a path with * to combine every path that starts with it (/blog/*).

Clicks from browser SDK 0.6 and later also carry their position on the page, and are drawn over the page itself. Live page loads your site in a sandbox, with no cookies or storage and no analytics sent, at the width of the chosen viewport. It needs your public site on one of the product's browser keys. Before loading it, AppHelm checks whether the site lets other sites show it in a frame. If it doesn't, the clicks are drawn over a blank page and the heatmap says why. To show your page there, allow AppHelm in a header on your site:

Content-Security-Policy: frame-ancestors 'self' https://apphelm.dev

This header replaces X-Frame-Options, which can't allow one other site. A development address such as http://localhost:3000, or a page served over http, can't be shown either. Use Screenshot to upload a full-page screenshot instead, or open the toolbar on your site to see the same layers over the real page.

The scrollmap shows, for each tenth of the page height, the share of page leaves that reached it. Depth arrives with $pageleave, so only the last page a tab showed is measured; single-page-app route changes are not. Rage clicks and dead clicks are listed per page as frustration signals.

#Filter the report

Click a page, referrer, UTM value, device, browser, OS, country, channel, source, campaign or landing page in the report to filter by it. Up to six filters combine. A filter keeps the sessions that match it, and every figure is then counted over those sessions, so "Referrer: google.com" shows which pages Google visitors went on to read, not only where they landed. While a filter is on, pageviews without a session (sent from a server) are left out, and conversion columns are not recounted.

#Keep your own team out

Visits from your own team are dropped before storage and never count toward usage. There are two ways to mark them: a flag on the events, or an excluded network, which also stops session replay and profiles from that network.

Flag signed-in staff. Put apphelm_internal: true on their events. register adds it to every later event, so set it before the first pageview: create the client without consent, register, then give consent.

No example for this step; showing JavaScript (browser).

const analytics = createBrowserSdk({ key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…" });
if (currentUser?.isStaff) analytics.register({ apphelm_internal: true });
analytics.setConsent({ analytics: true, replay: false }); // the first pageview now carries the flag

Exclude an office network. In Settings → Capture → Internal traffic, press Exclude this network from a browser on that network. AppHelm uses the network your request comes from (an IPv4 address whole, an IPv6 address cut to its /64), stores only a keyed hash of it with your label, never the address, and drops every browser request from it.

  • A workspace can exclude up to 20 networks. Each lapses after 90 days, because addresses get reassigned; exclude it again to renew it.
  • Only owners and administrators with access to every product can exclude networks.
  • Network exclusion applies to browser keys. Events your servers send are not affected.
  • Feature flags and survey eligibility still answer on an excluded network, so your team sees the product as visitors do.

Settings → Capture shows how many internal events were dropped over the last 30 days.

#Bots and abuse

The browser collector refuses, before storage and before it counts toward your allowance:

  • Bots and automation: any request with no user agent, a user agent that names a bot or crawler (Googlebot, AhrefsBot and the like), or one from a headless or scripted browser or HTTP client (HeadlessChrome, Puppeteer, Playwright, Selenium, Lighthouse, PageSpeed, curl, wget and others), and requests Cloudflare marks as a verified bot.
  • Floods: more than 240 requests a minute from one client address, or 2,400 a minute on one project key, per Cloudflare location. The address is used only as a keyed hash that changes daily, and is never stored.
  • Wrong origins: a project key only accepts requests whose Origin is one of the key's allowed origins.

Refused bot traffic gets a 202 answer so crawlers don't retry. Settings → Capture shows the bot and rate-limited counts. Lighthouse and PageSpeed runs are refused too, so their page loads never reach your web vitals.

  • Nothing before consent. Without analytics consent the SDK sends no events and writes nothing to storage.
  • What it stores. With consent, the browser SDK keeps the visitor's anonymous id in localStorage (apphelm.distinctId, and apphelm.user once identified) and the session id in sessionStorage (apphelm.sessionHash). The core SDK sets no cookies.
  • Framework helpers. The Next.js, Nuxt, SvelteKit and Angular server helpers keep the anonymous id in a first-party apphelm_id cookie so server-rendered flags match the browser. Pass cookie: false to the provider or plugin to leave cookies alone.
  • No cookieless mode. AppHelm doesn't count visitors who declined consent, by fingerprinting or otherwise. Expect your numbers to be lower than server logs by the share of visitors who decline.
  • Withdrawing consent. setConsent({ analytics: false }) stops sending at once and drops anything not yet sent. It doesn't delete the ids already in localStorage; remove those keys yourself if your policy requires it.
  • Retention. Pageviews follow your plan's capture retention. Touches of anonymous visitors are removed after 400 days; a direct touch that is not a visitor's first is removed with capture retention. An identified person's touches stay until the person is deleted. POST /api/v1/privacy/delete removes touches with the rest of a person's data.

Privacy, consent and data controls covers consent banners, masking and deletion for every product.

#Read the report with the API

GET /api/v1/query with kind=web returns the same report as JSON. It needs a workspace API key with metrics:read.

No example for this step; showing HTTP (curl).

curl "https://apphelm.dev/api/v1/query?productId=prd_…&kind=web&days=30" \
  -H "Authorization: Bearer $APPHELM_API_KEY"

The data object holds views, sessions, visitors, viewsWithoutVisitor, daily, pages, entryPages, exitPages, referrers, sources, devices, browsers, operatingSystems, countries, engagement (bounceRate, avgSessionSeconds, measuredSessions), vitals and acquisition, with a caveat that says what the numbers do and don't include.

  • days is 1 to 90 (30 by default). A longer range is refused with 422, never shortened.
  • The API report credits conversions by first touch and takes no filters; use the app for last touch and filters.
  • A key runs at most 60 queries a minute; above that the answer is 429 with Retry-After: 60.

Insights, dashboards and SQL covers trends, funnels and SQL over the same events, including path, referrer and utm_* breakdowns.

#Check that it works

  1. Look for the request

    In the browser's network tab, look for POST https://apphelm.dev/api/events about five seconds later (or when 20 events have queued). A 202 answer with accepted: false names the reason, such as bot_filtered, internal_traffic or collection_paused.

  2. Open the report

    Open Web for the product. Views appear within seconds. Bounce rate and session length appear once a session has ended, so close the tab and check again.

#Best practices

  • Ask for consent once, early. The first pageview carries the referrer and UTM tags that attribution depends on; it's recorded when consent arrives on that page.
  • Tag every link you place. Untagged ad and email clicks land in organic search, referral or direct.
  • Use the same id everywhere. Give the browser SDK the same user id your server uses for identify, so conversions join to the visits before them.
  • Call reset() on sign-out, especially on shared computers.
  • Leave router pageviews off while autocapture is on; turn them on only with autocapture: false.
  • Mark staff and offices as internal before you launch, so the first weeks of data aren't your own.

#Limits

What Limit
Report window 7, 30 or 90 days in the app; 1 to 90 days through the API
Rows 25 top pages and acquisition rows, 15 referrers and sources, 10 entry and exit pages, 10 per device, browser, OS and country
Filters 6 at once, one value per key
Visitor outcomes in the report 3 per product
Bounce threshold 10 seconds; session length capped at 4 hours
Excluded networks 20 per workspace, 90 days each
Collector rate 240 requests a minute per client address, 2,400 per project key, per Cloudflare location
Ad click evidence Kept 90 days

#Troubleshooting

Symptom Likely cause What to do
The report is empty No analytics consent yet, or the browser sends Global Privacy Control Call setConsent({ analytics: true }) from your banner; set debug: true to see why nothing is sent
Requests fail with 401 invalid_project_key The page's origin isn't one of the key's allowed origins (scheme and port count) Add the exact origin, such as https://www.example.com, to the key in Settings
Pageviews appear but bounce rate and session length are blank No $pageleave arrived: autocapture is off, or tabs are never closed in your test Turn autocapture on, then close the tab after a test visit
Every visit is a new visitor Storage is blocked or cleared (private windows), or reset() runs on every load Call reset() only on sign-out
Two pageviews for each navigation A router helper is on while autocapture already tracks history Remove pageviews: true, or set autocapture: false
No pageviews for a hash-routed app #/page changes don't change the path Call page() after each route change
/checkout or /billing shows no views These paths are never autocaptured Call page() on those pages if you need them counted
Paid clicks show as organic The ad URL has a click id but no utm_medium Add utm_medium=cpc (or paid_social) to the ad's final URL
Moving between two subdomains counts as referral Neither host is a subdomain of the other (docs. and app.) Expected; filter by channel or source, or serve both from one host
Your own visits show up Staff aren't flagged and the office network isn't excluded Use register({ apphelm_internal: true }) before consent, or exclude the network in Settings → Capture
The office network exclusion stopped working It lapsed after 90 days, or your address changed Exclude the network again from Settings → Capture
422 from /api/v1/query?kind=web days is above 90 Ask for 90 days or fewer