All questions

Running a full A/B test server-side from Laravel Blade, no SPA anywhere

Asked by bruno_s on

Bbruno_s

Classic Laravel app, everything rendered in Blade, no SPA and no plans for one.

I want to A/B test the pricing page hero. My question is whether the whole loop can stay server-side through the PHP SDK: variant assignment, stickiness across visits, and results measurement.

Or does some part of this inevitably need client JavaScript? I'd rather know before I start.

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

The whole loop stays server-side. The PHP SDK fetches slot content on the server, and Croct handles variant assignment and stickiness for you, so your Blade template just renders whatever comes back:

$content = $client->fetch('pricing-hero@1')->content;

You can verify what happened per request: the response metadata reports contentSource ("slot", "experience", or "experiment") along with the experimentId and variantId, so experiment participation is fully visible on the server side. Measurement runs against the experiment's goal in the dashboard, no client stats code needed.

A few Laravel-specific notes:

  1. Laravel has dedicated docs on top of the PHP SDK, as do Symfony and Drupal. Background on the PHP ecosystem support is in the PHP ecosystem SDKs announcement.
  2. The CLI generates a slots.stub file for PHP, the equivalent of the TypeScript slots.d.ts, so your slot content shapes are known to your tools.
  3. If you later want client-side interaction events (scrolls, clicks), you can layer the script tag on top. It is additive, not required for the test to assign, stick, or measure.
Was this helpful?
Still have questions?