Title: Error When Viewing Pages with Experiment Code
Last modified: August 20, 2016

---

# Error When Viewing Pages with Experiment Code

 *  [optimized-marketing](https://wordpress.org/support/users/optimized-marketingcom/)
 * (@optimized-marketingcom)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/error-when-viewing-pages-with-experiment-code/)
 * I have multiples sites that I use this plug-in with. It doesn’t seem to be happening
   on all pages. My sites are set up to not use www. at the beginning. If you put
   [http://www.mysite.com](http://www.mysite.com) it actually goes to mysite.com
   with no issues.
 * But when I have a page with the Google Content Experiment option checked and 
   I try to go to [http://www.mysite.com/Experimentpage/](http://www.mysite.com/Experimentpage/)
   it doesnt redirect to mysite.com/Experimentpage/ as it should it throws the following
   error.
 * “Warning: Cannot modify header information – headers already sent by (output 
   started at /home/bob/public_html/mysite.com/wp-content/plugins/google-content-
   experiments/class-wpe-GCE.php:42) in /home/bob/public_html/mysite.com/wp-includes/
   pluggable.php on line 881”
 * Let me know if you need more information
    Thanks Greg
 * [http://wordpress.org/extend/plugins/google-content-experiments/](http://wordpress.org/extend/plugins/google-content-experiments/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Glenn Mulleners](https://wordpress.org/support/users/glennm/)
 * (@glennm)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/error-when-viewing-pages-with-experiment-code/#post-3245060)
 * On wp-includes/pluggable.php (line 881) the _wp\_redirect_ is performed:
    `header("
   Location: $location", true, $status);`
 * Apparently there already is some output before wp_redirect is executed. I don’t
   know if this is the most beautiful option and if it will work, but let’s try 
   this:
    In **google-content-experiments.php**:
    - Place `ob_start();` between `*/` and `if ( !defined('WPE_GCE_PATH') )`
    - Place `ob_end_flush();` right before the closing `?>`
 *  Thread Starter [optimized-marketing](https://wordpress.org/support/users/optimized-marketingcom/)
 * (@optimized-marketingcom)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/error-when-viewing-pages-with-experiment-code/#post-3245064)
 * I added your suggested code but that just gave the same error.
 * I got it working another way by still using the ob_start(); but I had to added
   it to the function.php file.
 * The code I added to Function.php
 * //allow redirection, even if my theme starts to send output to the browser
    add_action(‘
   init’, ‘do_output_buffer’); function do_output_buffer() { ob_start(); }
 * After I verified this would work. I decided to go back and test your suggestion
   again. I added ob_start() and ob_end_flush(). Same error so I figured I would
   just try ob_start() at the begining of google-content-experiments.php and not
   add ob_end_flush();
 * Adding only ob_start() to google-content-experiments.php actually fixed the problem.
   I am not sure what ob_start(); does or if not including ob_end_flush(); would
   have any negative impact.
 * Let me know if you think this is a valid approach or not.
    Thanks Greg

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error When Viewing Pages with Experiment Code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-content-experiments_9db5c0.
   svg)
 * [Google Content Experiments](https://wordpress.org/plugins/google-content-experiments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-content-experiments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-content-experiments/)
 * [Active Topics](https://wordpress.org/support/plugin/google-content-experiments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-content-experiments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-content-experiments/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [optimized-marketing](https://wordpress.org/support/users/optimized-marketingcom/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/error-when-viewing-pages-with-experiment-code/#post-3245064)
 * Status: not resolved