Server Side Testing with PHP

Overview

This is a sample of PHP code with the purpose to enable AB testing server side. With this code, you should be able to AB test changes, on the server side, before the page has been served to the browser. 

Sample Code

This code will require that you create a normal Convert AB experiment, and do a small change on it, to be able to save it.

As a suggestion, go into the Visual Editor and under your Variation Menu > Custom Javascript enter the following:

// This is the variation.

With that change, you should be able to save it, and use that experiment to collect data, and analyze it using its report. 

Make sure you enter a condition that wont be able to be triggered in the test. You could just use a JS Condition with the value false to never trigger it another way.

To start you will have to find out the Project Number and Experiment id. You need this to include it in the code. 

This is way more efficient than getting them via an API, as this would delay the processing of the code. However, if this is what you need, we have an API available for you to use.

 

If you have any questions, let them us know through the support channels available to you.

Have more questions? Submit a request

Comments