Hi all, I have a redirect page/ Google Analyitics that I cannot get to work. With my php redirect at the bottom of the page I get this: I get the Warning: Cannot modify header information - headers already sent by (output started at /home/domain/public_html/directory/special/index.php:10) in /home/domain/public_html/directory/special/index.php on line 36 And if I put the redirect at the very top of the page, the page redirects perfectly. But then it fails to validate in googles validation page for setting up split testing of landing pages. I have tried various combinations of putting the redirect in various parts of the page, I just don't see it. This page is the conversion page that includes the javascript tracking: <?php header("Location: http://myid.vendor id.hop.clickbank.net/?tid=".$_GET['tid']) ;?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="robots" content="index,nofollow"> </head> <body> <!-- Google Code Page --> <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = 7787989879; var google_conversion_language = "en_GB"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; if (0.6) { var google_conversion_value = 0.6; } var google_conversion_label = "rqWfCP8yBDMxdn2Aw"; //--> </script> <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1054237388/?value=0.6&label=rqWfCP8yBDMxdn2Aw&script=0"/> </noscript> <script> if(typeof(urchinTracker)!='function')document.write('<sc'+'ript src="'+ 'http'+(document.location.protocol=='https:'?'s://ssl':'://www')+ '.google-analytics.com/urchin.js'+'"></sc'+'ript>') </script> <script> _uacct = 'UA-4704447-12'; urchinTracker("/0487705979/goal"); </script> </body> </html> Code (markup): I'm not a whizz on php so I would appreciate some advice. and I'll paypal you $5 to fix it. Thanks Mike
It's impossible to use a header redirect and also load Javascript on the same page. You can use a meta redirect though. <!-- Google Code Page --> <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = 7787989879; var google_conversion_language = "en_GB"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; if (0.6) { var google_conversion_value = 0.6; } var google_conversion_label = "rqWfCP8yBDMxdn2Aw"; //--> </script> <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <script> if(typeof(urchinTracker)!='function')document.write('<sc'+'ript src="'+ 'http'+(document.location.protocol=='https:'?'s://ssl':'://www')+ '.google-analytics.com/urchin.js'+'"></sc'+'ript>') </script> <script> _uacct = 'UA-4704447-12'; urchinTracker("/0487705979/goal"); </script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta HTTP-EQUIV="REFRESH" content="0;URL=http://myid.vendorid.hop.clickbank.net/?tid=<?php echo $_GET['tid']?>"> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="robots" content="index,nofollow"> </head> <body> <noscript> <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1054237388/?value=0.6&label=rqWfCP8yBDMxdn2Aw&script=0"/> </noscript> </body> </html> Code (markup):
Thank you. I thought this and I did have a meta redirect. But someone told me that my php redirect would work also. I've spent the last several hours trying to make the impossible work. Thank you for that.
you can get ride of this problem just starting object at first line of you php with this fnciton ob_start(); or you even can solve it just redirecting the page using java script.
I just tried it and this is the error I get back: ob_start(); Warning: Cannot modify header information - headers already sent by (output started at /home/mydomain/public_html/dir/special/index.php:2) in /home/mydomain/public_html/dir/special/index.php on line 2 Code (markup): ob_start(); <?php header("Location: http://myid.vendorid.hop.clickbank.net/?tid=".$_GET['tid']) ;?> <script language="JavaScript" type="text/javascript"> var google_conversion_id = 1054237688; var google_conversion_language = "en_GB"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; if (0.6) { var google_conversion_value = 0.6; } var google_conversion_label = "tttfCPTyYBDMxdn2Aw"; </script> <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1054237388/?value=0.6&label=tttfCPTyYBDMxdn2Aw&script=0"/> </noscript> <script> if(typeof(urchinTracker)!='function')document.write('<sc'+'ript src="'+ 'http'+(document.location.protocol=='https:'?'s://ssl':'://www')+ '.google-analytics.com/urchin.js'+'"></sc'+'ript>') </script> <script> _uacct = 'UA-4876147-12'; urchinTracker("/0486605979/goal"); </script> Code (markup): Thanks Mike
ob_start(); Warning: Cannot modify header information - headers already sent by (output started at /home/mydomain/public_html/dir/special/index.php:2) in /home/mydomain/public_html/dir/special/index.php on line 25 Code (markup): Thanks
ob_start doesn't allow you to have the user run javascript and then redirect them with header. It just allows you to put the header command on a line after the javascript and have it still work, but the only reason that it's able to work is because the fact that you called ob_start prevents the javascript from ever being sent to the user.
So are you saying in this case it would not work then? If it would how would I write the script above so that it would work? Thanks for your help. Regards Mike