Last active
October 24, 2016 03:03
-
-
Save jice-lavocat/67359a5d90bf7737263e8b504c98e58e to your computer and use it in GitHub Desktop.
Change a page content/layout with GA Experiments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Load the JQuery library --> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> | |
<script> | |
// Needs to be loaded after jquery | |
var chosenVariation = cxApi.chooseVariation(); | |
console.log("Experiments is ON. Visitor will see variant : ", chosenVariation); | |
// Define JavaScript for each page variation of this experiment. | |
var pageVariations = [ | |
function() { // Original: We don't change the page at all | |
console.log("variation 0 is used"); | |
}, | |
function() { // Variation 1 we show the CTA signup above the testimonials: | |
console.log("variation 1 is used"); | |
$("#testimonials").insertAfter("#signup"); | |
}, | |
]; | |
// Wait for the DOM to load, then execute the view for the chosen variation. | |
$(document).ready( | |
pageVariations[chosenVariation] | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment