028: Analytics ecommerce
A small e-commerce site wired to the built-in stdout and GA4 analytics collectors. Piko tracks every pageview automatically. Add-to-cart and checkout events attach revenue data and custom properties.
What this demonstrates
WithBackendAnalyticswiring the built-in stdout and GA4 collectors.piko.SetAnalyticsRevenueto attach monetary values to pageviews.piko.AddAnalyticsPropertyfor per-event custom properties.piko.SetAnalyticsEventNameto promote a pageview to a named custom event.piko.analytics.track(...)(frontend) for fully custom events emitted client-side from thepp-cartcomponent (add_to_cartandpurchase), while the backend promotes the automatic pageview to a namedpurchaseevent viaSetAnalyticsEventName.
Project structure
src/
cmd/main/main.go Bootstrap wiring the frontend analytics module and backend collectors.
pages/
index.pk A single shop page with products and an add-to-cart action.
actions/
cart/
purchase.go Records a purchase and emits the analytics event.
partials/ Shared layout and product-card partials.
components/ Client components that drive the analytics events.
How to run this example
From the Piko repository root:
cd examples/scenarios/028_analytics_ecommerce/src/
go mod tidy
air
The configured backend collectors receive every event. Swap them for a real collector (GA4, Plausible, Mixpanel) in production.