Goals
Goals define what success looks like for your experiments. Every A/B test needs a measurable outcome — goals are how you tell Apex what to measure.
What Is a Goal?
A goal is a specific user action that represents a conversion. When a visitor performs that action, Apex records it as a conversion event and attributes it to the correct experiment variant.
Goals are reusable. Create a goal once, then attach it to as many experiments as you need.
Goal Types
Apex supports four types of conversion goals:
| Type | What it tracks | Example |
|---|---|---|
form_submit | A form submission on the page | Newsletter signup, contact form, checkout form |
click | A click on a specific element | "Buy Now" button, CTA link, pricing toggle |
pageview | A visit to a specific page | Thank-you page, confirmation page, onboarding step |
custom_event | An event you send via the SDK | Video watched, file downloaded, feature activated |
Tip
form_submit and click goals work automatically with the tracking snippet — no code changes needed. Use custom_event when you need to track something the snippet can't see, like a server-side action.
Creating a Goal
Navigate to Goals
Open the Goals section in the Apex dashboard.
Choose a goal type
Select the type that matches the action you want to track: form submission, click, pageview, or custom event.
Configure the target
Each goal type has different configuration options:
- Form submit: Select the form by CSS selector or let Apex auto-detect forms on the target page
- Click: Provide a CSS selector for the element (e.g.
#cta-button,.pricing-link) - Pageview: Enter the URL path that counts as a conversion (e.g.
/thank-you) - Custom event: Define the event name that your code will send (e.g.
video_complete)
Name and save
Give the goal a clear, descriptive name. Good names describe the action and location: "Pricing page — Plan upgrade click" is better than "Goal 1."
The Goal Configurator
When you create a goal, the configurator helps you target the right element. For click and form_submit goals, you can:
- Enter a CSS selector directly if you know it
- Use the visual selector to point-and-click on the element you want to track
- Test the selector to verify it matches the right element on the page
Info
CSS selectors should be as specific as possible. Prefer IDs (#signup-form) or data attributes ([data-goal="signup"]) over generic class names that might change.
Connecting Goals to Experiments
Every experiment requires exactly one goal. When you create or edit an experiment, you select which goal defines success for that test.
The flow works like this:
- A visitor lands on the experiment's target page
- Apex assigns them to
controlorvariant_b - If the visitor performs the goal action, Apex records a conversion
- The conversion is attributed to whichever variant the visitor was assigned to
This attribution is automatic. The snippet tracks both experiment assignment and goal completion, then connects them using the visitor's anonymous ID.
Tracking Custom Events
For custom_event goals, send events from your code using the tracking snippet's API or the SDK:
// Client-side (snippet API)
window.apex?.track("video_complete", {
videoId: "intro-demo",
duration: 120,
});
// Server-side (SDK)
import { Apex } from "@anthropic/apex-sdk";
const apex = new Apex({ projectKey: "YOUR_KEY" });
await apex.track(visitorId, "video_complete", {
videoId: "intro-demo",
duration: 120,
});
The event name in your code must exactly match the event name configured in the goal.
Goal Metrics
For each goal, the dashboard shows:
- Total conversions — How many times the goal was triggered
- Conversion rate — Conversions divided by unique visitors
- Per-variant breakdown — Conversion rate for each experiment variant
- Trend — How the conversion rate is changing over time
These metrics update in real-time as the snippet collects data.
Best Practices
- One goal per experiment. Multiple goals make it hard to declare a winner. If you need to track secondary metrics, create separate goals and monitor them outside the experiment.
- Name goals descriptively. You'll reuse them across experiments — future-you will appreciate clear names.
- Prefer specific selectors.
#signup-ctais more reliable than.btn.primarywhich might match multiple buttons. - Test before activating. Use the goal configurator to verify your selector or event name works before running an experiment against it.