Quick and Dirty Split Testing With PHP

Two scriptlets lifted from Jack – the first will randomly forward each visit to a split test variant if there is a “gclid” variable occurring in the URL query string. (e.g. http://www.domain.com/?gclid=2234823958729385 ). This is the standard way Google passes visitors to a site via adwords.

This second little scriptlet first checks for the existence of a cookie variable “BTDT”. If it doesnt find BTDT in any cookie contents it sets the cookie, checks to see if the visitor arrived from adwords and then forwards the visitor to a random split test variant. If its not an adwords visitor it does nothing. If it does find a cookie it does nothing.