Splitlab

Documentation

WordPress

The Splitlab plugin adds the Splitlab engine to every page of your WordPress site. You don't need to edit your theme. If you run WooCommerce, the same plugin can also report orders as test revenue.

RequiresWordPress 5.7 or later, PHP 7.4 or later
WooCommerceOptional. Classic and block checkout, and High-Performance Order Storage (HPOS), are supported
Plugin slugsplitlab

Install

  1. In your WordPress admin, go to Plugins → Add New and search for Splitlab. Click Install Now, then Activate.
  2. Go to Settings → Splitlab.
  3. Paste your project key and click Save Changes. The project key is the data-project-key value in the dashboard under Install / SmartCode, on the Wordpress tab.
  4. Verify the install.

Plugin not in search yet?

The plugin is in review for the WordPress.org directory. Until it is listed, ask Splitlab support for splitlab.zip and upload it under Plugins → Add New → Upload Plugin. Updates then arrive through Plugins like any other plugin once the listing is live.

Nothing is printed on your pages until a project key is saved.

Settings

All settings are under Settings → Splitlab.

SettingDefaultWhat it does
Project keyemptyRequired. Which Splitlab project the site belongs to. Only letters, digits, _ and - are kept.
Anti-flickerOnHides the page until the engine has applied the visitor's variant, so they never see the original first.
Reveal anyway after3000 msIf the engine has not loaded by then, the page is shown anyway. Accepts 500 to 10000 ms.
Server API keyemptyOnly needed for WooCommerce revenue.
EnvironmentProductionLeave on Production. Staging points at Splitlab's internal test servers.

What the plugin adds to your pages

The plugin prints two scripts as the first thing in <head>, ahead of your theme's styles and scripts:

  1. The anti-flicker script (when it is on). It sets body { opacity: 0 } and reveals the page when the engine calls window.rmfk(), or after the timeout.
  2. The engine, loaded async from https://cdn.splitlab.io/cdn/engine.js, with your project key in data-project-key.

This is the same code as the install snippet, so everything on that page about consent, options and verifying applies here too.

Caching and optimisation plugins

Plugins that defer, delay or combine JavaScript break this setup in one of two ways:

  • If the anti-flicker script is delayed, visitors briefly see the original page before the variant appears.
  • If the engine is delayed until the visitor interacts, the page stays blank until the anti-flicker timeout.

The plugin marks both scripts so the common optimisers leave them alone:

OptimiserHow the plugin opts out
WP Rocket (Delay JavaScript execution)nowprocket attribute
LiteSpeed Cachedata-no-optimize="1" and data-no-defer="1"
Cloudflare Rocket Loaderdata-cfasync="false"
AutoptimizeWrapped in <!--noptimize--> … <!--/noptimize-->

If you use a different optimiser and see flicker or a blank page, exclude mvt-anti-flicker, mvt-engine-script and cdn.splitlab.io in its JavaScript settings.

Clear the page cache after installing

A full-page cache keeps serving pages built before the plugin was active. Purge it after you save the project key, or the snippet only appears as cached pages expire.

If your Splitlab project requires cookie consent, the engine stores nothing until the visitor grants it. The plugin adds nothing of its own on top of this. See the install snippet for how consent is signalled to the engine.

Troubleshooting

SymptomLikely causeFix
Verify finds no snippetPage cache still serving old pagesPurge the cache, then verify again
Verify finds no snippetProject key not savedCheck Settings → Splitlab
Original page flashes before the variantAn optimiser is delaying the anti-flicker scriptExclude it as described above
Page stays blank for a few secondsAn optimiser is delaying the engineExclude it as described above, or lower Reveal anyway after
Snippet appears twiceThe snippet was also pasted into a header plugin or the themeRemove the pasted copy; the plugin is enough

Uninstall

Deactivating the plugin removes the snippet from your pages. Deleting it under Plugins also deletes its settings. Order notes and order data written for WooCommerce revenue stay on your orders.

Prefer head code?

If you would rather not use a plugin, paste the install snippet into your theme's <head> or a "header code" plugin instead. Use one method, not both. WooCommerce revenue needs the plugin.