Server-side testing

Running tests server side makes it possible to run experiments on pricing or other aspects handled by your back-end. It’s also a great way to make sure there is no blinking at all for large changes.

To run a server-side test, simply:

1. Create an experiment in SiteGainer
2. Create the variations you intend to have ( you can leave them empty, or add some additional code that you might want to run in combination with your server-side changes )
3. Set your Goals
4. In Audience – choose manual activation ( at the top ). The audience will not be used with server-side testing.
5. Start the test

When this is done, run this basic logic in you server side code ( This example is in PHP ):

<?php
// Set the project ID ( Found in the SiteGainer dashboard
$sg_project_id = 19221323;
// Randomize varitation | rand(0, 2) = 3 variations | 0 is always Original
$sg_variation_id = rand(0, 2);
?>

When running SiteGainer, pass the variation like this:

<head> <!-- Can be in head or body-->
<script type="text/javascript" src="//d191y0yd6d0jy4.cloudfront.net/sitegainer_123123.js"></script>
<script>
	// Create an array
	var sg_force_variation = [];
	// Push the project and variation id into the array
	sg_force_variation.push({'project_id':<?php echo $sg_experiment_id?>,'variation_id':<?php echo $sg_variation_id?>});
	// You could also do a for-loop in PHP to force several projects & variations.
</script>
</head>

A psuedo-code example:

// ## Include SiteGainer [Front-end] ##
// In the head - load <script type="text/javascript" src="//d191y0yd6d0jy4.cloudfront.net/sitegainer_123123.js"></script>

// ## Get / Set project & variation [Back-end] ##
// Set project ID
// Check cookie, if there is no cookie for the above project id:
	// Set variation ID
// Else
	// Randomize a variation for the project id, and set it in a cookie (To make sure the visitor sees the same variation next visit).

// ## Output changes [Back-end] ##
// If variation = 0
	// Original - output: "<h1>SiteGainer - The all-in-one platform for A/B testing & CRO</h1>";
// If variation = 1
	// Variation 1 - output: "<h1>SiteGainer - #1 A/B testing platform in the world</h1>";
// If variation = 2
	// Variation 2 - output: "<h1>SiteGainer - The next-generation A/B testing platform</h1>";

// ## Track outcome [Front-end] ##
// Push variation to SiteGainer ( sg_force_variation )

Please contact us for further assistance with server-side testing!