DashForDevsDocs
DocsNewsAPI v1
dashfordevs.comSign in

© 2026 DashForDevs

DocsNewsdashfordevs.comLegalStatus
DocsAnalytics & TrackingStorefront Views
Introduction
Getting Started
Authentication
Products
Categories
Cart
Checkout
Blog
Reviews
Webhooks
Customers
Orders
Inventory
Shipping
Discounts
Affiliates
Email
Media & Files
Analytics & Tracking
Storefront ViewsGoogle Analytics (GA4)PostHogUTM TrackingConversion FunnelThoughtMetricFirst-Party Analytics (Insights)
Locations
Tax
Global Data
SEO
Error Handling
Geography
Finance
Automations
Page Types
Surveys
Billing & Subscriptions
Storefront Payments
SDK Reference
REST API
Storefront Architecture
Notifications
Security
Team & Permissions
Migrations & Import
Calendar & Appointments
Contact Forms
AI Bots
Dashboard API
Deployment
Changelog
Troubleshooting
Recipes
CLI & Deployment
Image Pipeline
White-label Platforms
Records Engine
Platform Modules
Platform Security
Site Keys & Client Sites
Use Cases
Operations

Storefront Views

Track page views and product views.

Updated September 8, 2026

On this page
  • Overview
  • Initialize Tracking
  • Track Page Visits
  • Auto Page Views
  • Custom Events
  • User Identification
  • REST API
  • Next Steps

Overview

Track page views and product visits on your storefront. DashForDevs provides built-in analytics with optional integration to PostHog and Google Analytics.

Initialize Tracking

typescript
import dash from "@/lib/dash"

const { active } = await dash.tracking.init()
// Initializes session tracking

Track Page Visits

typescript
// Track a product page visit
await dash.tracking.trackVisit({
  product_id: "prod_abc123",
  duration: 30,  // seconds spent
})

Auto Page Views

typescript
// Enable automatic pageview tracking for SPA navigation
dash.tracking.enableAutoPageviews()

// Disable when needed
dash.tracking.disableAutoPageviews()

Custom Events

typescript
dash.tracking.capture("add_to_cart", {
  product_id: "prod_abc",
  product_name: "Blue Dream",
  price: "29.99",
})

dash.tracking.capture("search", {
  query: "edibles",
  results_count: 15,
})

User Identification

typescript
// After login
dash.tracking.setCustomer("cust_abc123")

// After logout
dash.tracking.clearCustomer()

REST API

shell
# Get analytics config
GET /storefront/analytics/config
X-API-Key: pk_live_your_key

# Track visit
POST /storefront/analytics/track-visit
Content-Type: application/json
{ "product_id": "prod_abc", "session_id": "sess_123", "duration": 30 }

Next Steps

  • Google Analytics (GA4) — GA4 integration
  • PostHog — PostHog integration
  • UTM Tracking — Campaign tracking

What these events become once collected is covered in analytics and reporting.

PreviousFile Size LimitsNextGoogle Analytics (GA4)

On this page

  • Overview
  • Initialize Tracking
  • Track Page Visits
  • Auto Page Views
  • Custom Events
  • User Identification
  • REST API
  • Next Steps