Google Content Experiments

Google Analytics Content Experiments only for AdWords

Google Content ExperimentsGoogle Analytics Content Experiments are a great and supremely simple way of A/B testing your landing pages.

How does it work?

Once you insert your Google Content Experiment code on your landing pages and create an experiment in your Google Analytics, it will start redirecting your traffic to your landing page versions in percentages that you have defined in the experiment.

Official Help on setting up content experiments

This is a great way to test landing pages, but the problem is it will redirect all your traffic, irrespective of source. Now ideally I wouldn’t want to do that for the following reasons:

  •  When you are working with direct/referral traffic it could be problematic because that traffic is looking for, or referred to, a specific page, which should be found and directed to, rather than redirecting to another page.
  • If you are trying to test the home page vs sub-page traffic for your AdWords conversions and you have the Google Content Experiment code on your home page, it could start redirecting your organic/direct/referral traffic to that sub-page randomly. This could be potentially chaotic.

Now there are other ways to achieve this via AdWords by creating duplicate ads, but in that case, for a real A/B test you may have to change your strategy for ad rotation settings which may not be desirable. Even after changing that, this method may not give you as much insight as Google Analytics Content Experiments will.

How can you rectify this?

This is, quite surprisingly, the simplest part of the exercise. The hard part is analyzing the data.

Your normal content experiment code looks like this

Where ,‘xxxxxxx-x’ will actually be a number representing your experiment id.

You will need to tweak this code, just a little bit, as follows:

How does this work?

“Programs must be written for people to read, and only incidentally for machines to execute.” ― Hal Abelson, Structure and Interpretation of Computer Programs
This is my favorite quote about programming and that’s why I love explaining how it works.

if (document.referrer.indexOf('adurl') > -1 && document.referrer.indexOf('google') > -1)

This code checks if the referrer URL consists of strings (words) “adurl” and “google” and only fire function “utmx” if both of these words exist in referring URL.

Why these 2 words?

“adurl” – The value of this parameter is your destination URL defined in AdWords and will always be part of the referring URL in the case of an AdWords click. Along with this, we also want to be absolutely sure we are checking this code if “Google” is part of the referring URL. This will always be the case for an AdWords hit, even for the display network.
If you want to dig deeper you can even use value track parameters to fire Content Experiments only on certain keywords (e.g. brand / non brand), certain campaigns / AdGroups, certain devices, etc.

Hope you enjoy digging deep and sharing your experiences with us.

P.S : This script will work for GA Asynchronous as well as Universal Analytics



Philly Marketing Labs


1150 First Avenue, Suite 400 King of Prussia, PA 19406
(877) 373-2605
[email protected]