WordPress
The Koryla WordPress plugin handles traffic splitting server-side using PHP — no npm, no build step, no JavaScript in the browser.
How it works
- Plugin fetches your active experiments from the Koryla API (cached in WP transients for 5 minutes)
- On each page request, it checks
$_COOKIEfor aky_{experimentId}cookie - If no cookie → weighted random assignment → sets cookie via
setcookie() - If the assigned variant is not the control →
wp_redirect()to the variant URL
Everything runs in PHP during template_redirect, before WordPress renders the page.
Install
Manual:
- Download
koryla.phpfrom the Koryla repo - Place it in
/wp-content/plugins/koryla/koryla.php - Go to WordPress Admin → Plugins → Installed Plugins
- Activate Koryla
WordPress.org listing coming soon. For now, install manually.
Configure
- Go to WP Admin → Koryla
- Paste your API key (
sk_live_...from Koryla Dashboard → Settings → API Keys) - Click Save Settings
Your active experiments will appear in the panel below the settings form.
Create variants in WordPress
The plugin relies on variant URLs existing as real WordPress pages or custom routes. Typical setup:
| Page | URL | Role |
|---|---|---|
| Original homepage | / | Control |
| Variant homepage | /homepage-v2 | Variant B |
Create the variant page in WordPress normally (or as a custom template), set it to draft or private if you don't want it discoverable via the sitemap. The plugin redirects to it server-side regardless of its publish status.
Tip: To hide variant pages from search engines, add
noindexto the variant page's SEO settings (Yoast / RankMath / etc.).
Verify it's working
Visit your homepage in an incognito window. Open DevTools → Application → Cookies — you should see a ky_{experimentId} cookie set by the server.
Clear the cookie and reload several times to confirm traffic is being split between your variants.
Limitations vs edge approach
| WordPress plugin | Cloudflare Worker / Netlify Edge | |
|---|---|---|
| Redirect visible to browser | Yes (302) | No (transparent rewrite) |
| Runs in | PHP / app server | CDN edge (Cloudflare / Netlify) |
| Latency | ~1ms in-process | ~0ms (edge, before origin) |
| SEO impact | Minimal (same-session redirect) | None |
For large sites where SEO and performance are critical, pair the WordPress plugin with a Cloudflare Worker for the full edge approach.