AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
1.8K members online now
1.8K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Content experiments -- browser-only version not working

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I'm trying to implement a browser-only content experiment on my site (intended for health care professionals only) using jQuery to provide the experiment variations.

 

Two questions.

 

  1. When I go to the page the experiment is supposed to be loading on I don't see the MPU I created using jQuery. 
  2. When I look in GA I see the experiment is tracking sessions across the site. 

 

 

In the experiment I'd like to test phrases in an MPU-like widget I'm using to drive users from a piece of content  to a quick quiz about the content. 

 

I followed this guidance on developers.google.com.

 

In GA I set up a goal where the destination is the page I want users to go to.

 

I created the experiment code as below.

 

<!--This file to fall BEFORE the GA snippet and AFTER the Jquery file.

 Start GA Experiments -->



<!--my experiment ID from GA-->
<script src="//www.google-analytics.com/cx/api.js?experiment=Z8LFGRGsSs676EMDT-afmQ"></script>	

<script>
  // Ask Google Analytics which variation to show the user.
  var chosenVariation = cxApi.chooseVariation();
</script>

<script>

var pageVariations = [
  var original = "Take a quick quiz";
  var xOne = "Test your knowledge";
  var xTwo = "Test and reflect";
  var xThree = "Test your learning";
  var xFour = "Answer questions";
  var xFive = "Test yourself on...";
  var testText = ;
  var mcq = $('<a href="/mcq/index/id/126"><div id="mcq-promo"><p id="mcq-call-out">' + testText + '</p><img id="mcq-feature"src="/shared/media/experiments/ideas.png" width="212"><br><p id="mcq-strap"> Dyspepsia and Gord</p><img id="cpd"src="/shared/media/experiments/cpd.png" width="35"></div></a>');
  function() { 
   testText = original;
    $('.bs-docs-example').after(mcq);
  },  
    function() { 
    testText = xOne;
    $('.bs-docs-example').after(mcq);
  },
    function() { 
    testText = xTwo;
    $('.bs-docs-example').after(mcq);
  },
    function() { 
    testText = xThree;
    $('.bs-docs-example').after(mcq);
  },
    function() { 
    testText = xFour;
    $('.bs-docs-example').after(mcq);
  },
    function() { 
    testText = xFive;
    $('.bs-docs-example').after(mcq);
  }
];

<!--Wait for the DOM to load, then execute the view for the chosen variation.-->
$(document).ready(
  $('head').append('<link href="/css/experiments.css" rel="stylesheet" type="text/css">');
<!--Execute the chosen view-->
  pageVariations[chosenVariation]
);
</script>


<!-- End GA Experiments -->

In step 2 of the content experiment I set it up with the original page with the url and the variations with just 1.com, 2.com and so on.

 

Could I get some help with this? I've passed it to my developer but neither of us understand how to get the experiment to work using browser-only variations.

 

 

1 Expert replyverified_user

Re: Content experiments -- browser-only version not working

Google Employee
# 2
Google Employee
Did you got any javascript errors in your page?
Could you perhaps try out a simpler version first?