We need to add this code to WordPress theme’s header.php file. Once added, this code will start redirecting all visitors to a variation of your testing page. To add the split test code, we need to paste this code in theme’s header.php file:

<?php if (is_page($page_id)) :
//Add Google Analytics Content Experiment
 ?>

Paste content experiment code here 

<?php endif; ?>

We need to replace $page_id with the id of the original page.
If we don’t want to modify the code in the theme, we can use this plugin called Google Content Experiments (https://wordpress.org/plugins/google-content-experiments/)

February 23, 2015

A/B Split Testing in WordPress using Google Experiments (within Analytics)

We need to add this code to WordPress theme’s header.php file. Once added, this code will start redirecting all visitors to a variation of your testing […]