# A/B testing

You could use A/B testing to test different variations of the same tour. This can help you tweak your tours and achieve the optimal onboarding experience.

## 1. Add HelpHero.update() script

Add a script after your after your HelpHero installation scripts.

```html
<script>
HelpHero.update(function(user) {
  // user is already assigned variant do nothing
  if (user.variant) return null

  var variants = ['A','B']
  // assign user to variant
  return { variant: variants[Math.floor(Math.random() * variants.length)] }
})
</script>
```

:::note
Note: Returning null when user is already in a variant ensures the user is only assigned to a variant once.
:::

## 2. Setup tour variants with funnels

Now that user is assigned to a variant, we can create two variants of a tour. The first tour will have a funnel step targeting variant `A` and the second tour targeting variant `B`.

![](/docs/images/funnel-split-testing@2x.webp)
