Technical Implementation

Performance Split A-B Testing with PageSpeed

When a visitor first arrives on a site with this feature enabled PageSpeed chooses an experiment from among the ExperimentSpecs. If you are running your experiments on less than 100% of your visitors, some will be assigned to "no experiment", which PageSpeed represents as id=0. It generates the page in accordance with the ExperimentSpec and then sets a cookie valid for one week, so that on future page loads it knows which ExperimentSpec to apply to this visitor:

Date: Thu, 10 May 2015 14:19:43 GMT Server: Microsoft IIS .. Accept-Ranges: bytes Set-Cookie: PageSpeedExperiment=3; Expires=Thu, 17 May 2015 14:19:43 GMT;; Path=/

You can test this on your site with the curl program:

$ curl -D- -o /dev/null http://yoursite ... Set-Cookie: PageSpeedExperiment=1; ... ... X-IISpeed: ... ...

If you don't see a Set-Cookie header in the output, this feature isn't set up properly. If you don't see an X-Page-Speed or X-IISpeed header ,PageSpeed isn't running. On each page PageSpeed adds some JavaScript to set a Google Analytics custom variable:

_gaq.push(['_setCustomVar', 1, 'ExperimentState', 'Experiment: 4']);

While it does try to detect when a page already is using Google Analytics and add to it only what it needs, this is imprecise and can get it wrong. We recommend that you let PageSpeed insert the only snippet. If you need to call other tracking methods , for example to set the sample rate for your site, you can do this by adding to the _gaq array within <head>. The code to do this for setting the site sampleRate to 80% would be:

_gaq = _gaq || []; _gaq.push(['_setSampleRate', '80']);