View Single Post
  #4 (permalink)  
Old 12-11-2007, 06:05 AM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,226
Thanks: 2
Thanked 82 Times in 82 Posts
Default Re: How to add Google Analytics to every page on your osCommerce eCart

One problem that you're likely to encounter if you use SSL on the server is that you will get a security error when your browser changes from http to https. To get around this, you use https://ssl.google-analytics.com/urchin.js instead of the normal Google address when in SSL mode. To enable OSC to switch between the two, you delete the urchin call from the example above and insert this snippet immediately before the last ?>

PHP Code:
if ($request_type == 'SSL') { 
echo 
'<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>'
} else { 
echo 
'<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>'

I used the OSC variable $request_type in that example, if you want to do the same thing on another system, then use this more generic if statement in place of the one used above.

PHP Code:
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') { 
__________________
Lawrence
Reply With Quote