As a product owner for a 2million+ unique per month site, I want to do some A/B testing that I can track with Google Analytics goals, without paying the high fees for other online testing services. Using Google's own Content Experiments requires redirects using JS, which I don't want to risk the page load performance hit and have the freedom to use more than the 5 variations that CE limits you to.
This answer piqued my interest in using Route53 to avoid Google Content Experiments:
Google Analytics Content Experiments A/B testing server-side code without page refresh
I would like to know how I can serve and track these variations.
As I understand it now, Route53 functions at the DNS level and can load balance traffic to different IPs, so I could serve mydomain.com 50% / 50% to 200.0.0.1 and 200.0.0.2. I can then use server-side code to determine the IP being used and serve different JS tracking code for Google Analytics.
Then if users do or do not reach my GA Goal page, I can measure the effectiveness of my campaign?
Is that about right or am I missing something within the GA or site setup?
If you are already using Route53 and don't mind tracking different tacking codes separately, then you can use a bit of server side code to select the correct tracking code for that ID. Here is an example in PHP.
<?php
var $serverIp_trackingCodes_map = array(
'192.168.1.1' => 'UA-XXXXX-1',
'192.168.1.2' => 'UA-XXXXX-2',
'192.168.1.3' => 'UA-XXXXX-3',
'192.168.1.4' => 'UA-XXXXX-4'
);
?>
<script type="text/javascript">
//The usual ga tracking code
var _gaq = _gaq || [];
//Pass in the tracking code for that server
_gaq.push(['_setAccount', '<?php echo $serverIp_trackingCodes_map[ $_SERVER["SERVER_ADDR"] ] ?>']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
But it might be much easier to use one tracking code and set a custom variable with the server name or ip. This can later be used as a filter in reporting.
<script type="text/javascript">
//The usual ga tracking code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//Set the custom variable
_gaq.push(['_setCustomVar', 1, 'ServerIP','<? echo $_SERVER["SERVER_ADDR"]?>']);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With