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.
  • For "goal-only" Pages that use the SDK's pollOnRules option, the SDK now starts a bounded immediate-mode retry (the same behavior as targeting Pages) so JavaScript-condition goals attach reliably without waiting for a URL change.
  • 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.
  • The experiment list and detail header show a 'ready-to-launch' status. The experiment QA tab contains Open forced preview, Copy preview URL, and Show QR controls when a preview URL is available.
  • 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.

Note: After an experiment's results are reset (a new assignment epoch), goals configured with count-once will "re-arm" so returning visitors' conversions can be counted again. Returning visitors keep their previously-assigned variation and are not re-randomized by this reset. (See release notes for the committed behavior.)