My client is running a website that runs on a free ecommerce script. The scripts support says to include the google analytics code in the themes > core file i.e., there is a theme/core.php file. In that before close HTML, he is supposed to insert google code. # Add WYSIWYG (if found) to output IF ($_CCFG['WYSIWYG_CLOSE']) {$_out .= $_CCFG['WYSIWYG_CLOSE'];} # HERE IS WHERE THE CODE IS TO BE $_out .= '<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-1234567-89"); pageTracker._trackPageview(); } catch(err) {}</script>' # Close html $_out .= '</body>'.$_nl; $_out .= '</html>'.$_nl; PHP: But all we get is a blank page. Another person said this Any idea ?!?!?!?!?!?
you should learn php first 1.when u add a value to a php variable you shd escape string 2. you did not ended the statement by semicolon 3. write a simple program in php that echo google analytics data on screen using variable thanks I hope it will help you Regards Alex Regards Alex
Try this: <?php // Add WYSIWYG (if found) to output IF ($_CCFG['WYSIWYG_CLOSE']) { $_out .= $_CCFG['WYSIWYG_CLOSE']; } // HERE IS WHERE THE CODE IS TO BE $_out .= <<<GOOGLE <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-1234567-89"); pageTracker._trackPageview(); } catch(err) {}</script> GOOGLE; // Close html $_out .= '</body>'.$_nl; $_out .= '</html>'.$_nl; ?> PHP:
Hey thanks a lot. That seems to be working. Page is loading fine and GA says tracker installed. Just waiting to see reports in GA Thanks again.