Usage

Goals

The first step is to create a goal through the UI. Name it whatever you want (for example "Mailing List Signup" or "Add to Basket") and give it a unique handle.

Triggering goals

Now you want to trigger that handle in your code - to do that simply call:

\Thoughtco\StatamicABTester\Facades\Goal::completed('your-goal-handle')

If your goal is completed on a page, you may just want to use the antlers tag:

{{ ab:goal:completed handle="your-goal-handle" }}

Alongside the handle, we also log the time the goal was completed, the user's IP, and their ID if they are logged in.

You can also (optionally) record failures, if your test requires it:

\Thoughtco\StatamicABTester\Facades\Goal::failed('your-goal-handle')
{{ ab:goal:failed handle="your-goal-handle" }}

Javascript Helper

If you need to trigger goals from Javascript, include the {{ ab:js }} in your layout, then:

To register a hit on an experiment:

abTester.hit('experiment-id', { custom: 'data' })

To register a goal completed:

abTester.completed('goal-id', { custom: 'data' })

To register a goal failure:

abTester.failed('goal-id', { custom: 'data' })

Previous

Configuration

Next

Experiments