Merchants & developers

Metrics, goals, and conversion tracking

Creates reusable success events for experiments: click, pageview, custom, revenue, and Shopify-connected conversion goals.

Simple terms

Metrics tell Apex what success means for a test: a click, pageview, custom event, revenue event, or Shopify event.

Creates reusable success events for experiments: click, pageview, custom, revenue, and Shopify-connected conversion goals.

Routes

  • /goals
  • /goals/new
  • /goals/new/visual

Implementation behavior

  • A Goal stores type, selector, URL pattern, event name, capture rules, text matching, revenue settings, and count-once behavior.
  • Click goals bind to selectors in the SDK; optional capture rules can store element text, value, attribute, or dataset values.
  • Pageview goals match URL patterns after the SDK sees a page event.
  • Custom and revenue goals are tracked through SDK calls or Shopify event integrations.
  • Experiments attach goals through ExperimentGoal, with one goal marked primary for readback and launch criteria.

How to use it

  • Create reusable metrics before building an experiment.
  • Use click goals for UI actions, pageview goals for route arrival, custom goals for product events, and revenue goals for order value.
  • Verify selectors in QA before launch.
  • Mark one primary metric per experiment and keep secondary metrics for diagnostics.

When not to use it

  • Do not use a click goal when the real outcome is revenue or checkout completion.
  • Do not use fragile selectors that depend on generated class names if a stable selector exists.
  • Do not mark multiple goals as primary for the same experiment decision.

Implementation source

  • Metric pages live under src/app/(dashboard)/goals.
  • Handlers live under /api/goals, /api/generate-selector, and goal-verification experiment QA routes.
  • The SDK binds goal listeners and sends matching events through the Worker into Tinybird.

Data and API

  • Prisma models: Goal, ExperimentGoal, ShopifyEventSetting.
  • APIs: /api/goals, /api/goals/[id], /api/generate-selector, /api/experiments/[id]/qa/goal-verification.
  • Events land in Tinybird events with event_type, experiment_id, variation_id, properties, and timestamp.

Failure modes

  • Selector does not fire: inspect DOM timing, selector specificity, and whether the element is replaced after SDK binding.
  • Revenue missing: confirm Shopify/web pixel settings or custom revenue payload shape.
  • Conversion rate looks wrong: check count-once rules, bot/internal traffic, and whether the primary goal is attached to the right experiment.