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
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. Asearch 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’sattribution
(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 & Traffic —
session_start+page_viewproduce sessions, visitors (new vs returning, viavisitor_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_closeduration_mspowers average time-on-page. - Traffic sources & Revenue-by-source — the
utm_*onsession_startbecome the Traffic sources breakdown; joined with orders that carry the matchingsession_idin theirattribution, 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_idacross surfaces: productview/add_to_cartcome from the Events API, “reached checkout” from a stock reservation, and “purchased” from a paid order whoseattribution.session_idmatches. Use one stablesession_idfor a shopper’s whole journey or the funnel can’t connect the stages. - Landing / exit pages — from the
pathon eachpage_view. - Content funnel —
post_view/lookbook_viewandcontent_click(withcontent_id+content_product_id) feed the Content tab’s views → clicks → orders → revenue per post/lookbook, closed by orders carryingattribution.content_id.
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.

