Skip to main content
The AnalyticsService class (accessed via client.analytics) records first-party storefront analytics — page views and session starts. These power the merchant’s Store Analytics: traffic and audience, the conversion funnel, top products, and revenue-by-source. You send only the lightweight signals a browser has; the device, browser, operating system, and approximate location (country/region) are derived automatically from the request. The endpoint is publishable-key accessible, so you call it directly from the browser. It returns immediately and is processed in the background — sending an event never blocks the page.

Methods

collectAnalyticsEvent

Record one analytics event. Fire session_start for the first event of a new browsing session, then page_view on each route change.
Response
Every event type returns the same acknowledgement with a 202. The collector is a fire-and-forget beacon: it never returns data to read, and a failed write is never surfaced to the shopper. Parameters:
Persist visitor_id across sessions (e.g. in localStorage) and keep one session_id per browsing session. Send session_start once per session and a page_view on every route change — that’s all that’s needed for the full traffic, funnel, and revenue picture.

What you don’t send

Device type, browser, operating system, and country/region are detected from the request automatically — there is no client-side tracking script to add and no fingerprinting. Only the pathname is stored (query strings are dropped), keeping the capture privacy-light. A search or search_result_click event is stored without a customer, even when one is signed in and customer_id is sent. The reporting question is how a search term and its results perform, which the term, the product and the counts answer on their own.

Attributing revenue to a source

To see which traffic sources actually drive revenue (not just visits), pass the session’s first-touch attribution when you create the order — see Orders. The order’s attribution (session_id + the UTM parameters) lets Store Analytics join revenue back to the campaign that brought the shopper in.

What the merchant sees in Store Analytics

These events are the raw material behind the merchant’s Store Analytics dashboards in Galactic Core Admin. Nothing sent here is shown to shoppers; it is aggregated into daily rollups the merchant reads:
  • Overview & Trafficsession_start + page_view produce sessions, visitors (new vs returning, via visitor_id), pageviews, pages/session, and bounce rate. The device / browser / OS and country / region / city derived from each request become the Devices, Countries, and Cities breakdowns. page_close duration_ms powers average time-on-page.
  • Traffic sources & Revenue-by-source — the utm_* on session_start become the Traffic sources breakdown; joined with orders that carry the matching session_id in their attribution, they become Revenue by source (which campaigns actually convert).
  • Conversion funnel — the funnel stages (Viewed → Added to cart → Reached checkout → Purchased) are stitched by session_id across surfaces: product view / add_to_cart come from the Events API, “reached checkout” from a stock reservation, and “purchased” from a paid order whose attribution.session_id matches. Use one stable session_id for a shopper’s whole journey or the funnel can’t connect the stages.
  • Landing / exit pages — from the path on each page_view.
  • Content funnelpost_view / lookbook_view and content_click (with content_id + content_product_id) feed the Content tab’s views → clicks → orders → revenue per post/lookbook, closed by orders carrying attribution.content_id.
Because these are the only inputs to those dashboards, the completeness of what you send maps directly to what the merchant can see — e.g. omit utm_* and there’s no revenue-by-source; reuse one session_id per journey and the funnel lights up. The rollups recompute continuously, so recent activity shows up within minutes.

Response Codes