Run Split Tests (or A/B tests) with the power of Svelte(Kit). Split tests (or A/B tests) allow you to display different features or variants to test their effectiveness. Unfortunately popular options are very pricey, bloated, and don't work SSR. This package attempts to remedy all of that.
This package works with Svelte and SvelteKit.
- Works SSR
- Works with or without Kit
- Works with GTM and GA4, or any other analytics solution
- Lightweight
- Free, of course
Demo and Docs: https://svelte-split-testing.playpilot.com/
Install using Yarn or NPM.
yarn add svelte-split-testing --dev
npm install svelte-split-testing --save-dev
Include the component in your app.
import { SplitTest } from "svelte-split-testing"
<SplitTest>...</SplitTest>
For more configuration refer to the documentation: https://svelte-split-testing.playpilot.com/
This is a list of all configurable properties for each component and function.
Property | Default | Description |
---|---|---|
key | 'Some Key' | Key used to identify the current Split Test. This is primary used during analytics tracking. |
variants | ['Variant A', 'Variant B'] | An array of variant names. Can be as many variants as you like. What the names are is not important, but they show up during analytics tracking. |
onView | null | Optional function to be passed to track views of the current variant. Replaces the default GTM method. |
Property | Default | Description |
---|---|---|
serverCookies | null | Cookies object as served from +layout.server.js during SSR. |
options | { userIdentifier, cookieName } | Object of configurable options |
options.userIdentifier | null | An optional user identifier to use as the identifier. This is used to show a user the same split test across different devices, as long as they have the same identifier. If an identifier was already set before the user identifier |
options.cookieName | 'splitTestIdentifier' | The name of the cookie used to store the split testing identifier. |
Property | Default | Description |
---|---|---|
options | { userIdentifier, cookieName } | Object of configurable options |
options.userIdentifier | null | An optional user identifier to use as the identifier. This is used to show a user the same split test across different devices, as long as they have the same identifier. If an identifier was already set before the user identifier |
options.cookieName | 'splitTestIdentifier' | The name of the cookie used to store the split testing identifier. |