Splitworthy documentation

PHP, Laravel & Symfony

Install on PHP-rendered websites with the shared browser engine and safe template output.

Verify your PHP website

Register the HTTPS domain in Websites and prove ownership with the DNS TXT or HTTPS verification-file challenge. PHP sites use the same experiments, configuration, consent and Results as JavaScript sites. WordPress customers should use the existing Experiment Connector plugin.

The repository includes integrations/php/splitworthy.php and its README. This is a PHP 7.3+ template helper, not a Composer package or server-side variation engine. Check the published 0.5.0 browser asset is available before deploying.

Print the SDK inside your shared head

Copy the helper into your app, include it and print its output early in the shared head. Replace YOUR_PUBLIC_SITE_ID with the real public site_ identifier; the helper rejects the placeholder until replaced. Only install one SDK per page.

Configuration is safely JSON-encoded; an optional CSP nonce is escaped for the script attributes. Pass a nonce created by your application when your policy requires one. No private installation secret or database key belongs here.

php
<?php require_once __DIR__ . "/splitworthy.php"; ?>
<!doctype html>
<html><head>
<?php echo splitworthy_head("YOUR_PUBLIC_SITE_ID"); ?>
</head><body><!-- Your original page content --></body></html>

Laravel Blade and Symfony Twig

Register/include the helper using your application’s normal bootstrap. In Blade output only the trusted helper return value using the example below. In Symfony call the helper in your controller, pass its HTML to Twig and render that variable with the raw filter. Never apply raw output to arbitrary visitor-provided HTML.

text
{{-- Laravel Blade; use your actual public site ID and CSP nonce --}}
{!! splitworthy_head($publicSiteId, $cspNonce) !!}

{# Symfony Twig; generated by the helper in your controller #}
{{ splitworthyHead|raw }}

Consent and genuine PHP form success

Connect your browser consent manager to grantConsent and revokeConsent on window.testwell. Consent remains required by the helper; it never enables tracking merely because a page was generated by PHP.

For a form or checkout, configure a pageview goal on a real confirmation pathname reached only after success, or fire a configured custom goal in the browser after confirmed success. Do not send visitor events directly from PHP: this release has no authenticated server-conversion API. A page visit is not independent proof of a sale.

javascript
// In the real consent banner callbacks:
window.testwell?.grantConsent();
window.testwell?.revokeConsent();
// Only after a confirmed successful action and an eligible prior exposure:
window.testwell?.trackGoal("enquiry_completed");

Limitations and production validation

PHP only delivers the browser integration; no server-rendered assignment or SSR cookie evaluation is supplied. Original content must remain usable during missing consent, unavailable SDK/configuration and emergency disable. Do not claim zero flicker or a published Composer package.

On an authorised staging site verify installed JavaScript, domain connection, assigned content, real exposure, confirmed goal and Results read-back. Test consent withdrawal, repeated conversions, CSP, caches and website disable. PHP helper checks are not proof of a real external installation.