Support » Plugins and Hacks » Error When Viewing Pages with Experiment Code

Error When Viewing Pages with Experiment Code

  • optimized-marketing


    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 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/ 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


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author glennm


    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 ?>


    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() {

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Error When Viewing Pages with Experiment Code’ is closed to new replies.