Shopping Cart Forum

Go Back   eShop Forums - eCommerce Help Forum for Shopping Cart Owners. > Shopping Cart Software > Zen Cart & osCommerce
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Zen Cart & osCommerce Tips, advice and help on how to use the most popular free E-commerce shopping carts available.

Reply
 
LinkBack (2) Thread Tools Display Modes
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 18-08-2007, 09:12 AM
Lawrence Lawrence is online now
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,220
Thanks: 2
Thanked 81 Times in 81 Posts
Default How to add Google Analytics to every page on your osCommerce store

First thing you need to do is to open an account with Google, you can do that here http://www.google.com/analytics/

Once you have an account you will be given a snippet of code to install on each page you want tracked. On a normal HTML page you will place this just before the </body> tag at the bottom of each page. You may read on some other sites that should place this at the top of the page, you should ignore such advice because if it's placed at the top of a page and there is a delay in the communication with the Google server then your page won't load load until it's finished, resulting in slow page load times and annoyed customers. If placed at the bottom, then the page will load first and be usable before Google has done it's bit.

The code snippet looks something like this

HTML Code:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2462717-1";
urchinTracker();
</script>
To insert it into each page of OSC (except the admin pages) you need to open /includes/footer.php

At the bottom of which you will see something like this.

PHP Code:
<?php
  
if ($banner tep_banner_exists('dynamic''468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><?php echo tep_display_banner('static'$banner); ?></td>
  </tr>
</table>
<?php
  
}
?>
You need to add your Google code to it like this
PHP Code:
<?php
  
if ($banner tep_banner_exists('dynamic''468x50')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><?php echo tep_display_banner('static'$banner); ?></td>
  </tr>
</table>
<?php
  
}
?>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2462717-1";
urchinTracker();
</script>
That's all there is to it, you now have Google Analytics on every user page of your osCommerce shopping cart.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-11-2007, 12:37 AM
ICTADVIS ICTADVIS is offline
Junior Member
 
Join Date: Nov 2007
Location: Scotland
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Re: How to add Google Analytics to every page on your osCommerce eCart

Hi Lawrence

I look after an OSCOMMERCE site for a client but it would not appear that the file footer.php situated within INCLUDES is supporting my clients site.

The footer information I do see seems to be editable in a file titled english.php that has a section contained within it saying define footer text and here I can edit text that I want to appear on every page. However, the actual footer file situated within INCLUDES looks nothing like what you refer too.

Appreciate your advice on where I might be going wrong?
__________________
ICTADVIS
www.ictadvisor.com
info@ictadvisor.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-11-2007, 04:32 AM
Lawrence Lawrence is online now
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,220
Thanks: 2
Thanked 81 Times in 81 Posts
Default Re: How to add Google Analytics to every page on your osCommerce eCart

Hi ICTADVIS

It is possible that your client is running an older version of osCommerce than the one I used in my example so the code will be slightly different. The principle is still the same, place the Analytics code after the last ?> in includes/footer.php. To check it's actual position on a page, open the site in your browser then view the source for the page. It should appear just before the </body> tag.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-11-2007, 06:05 AM
Lawrence Lawrence is online now
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,220
Thanks: 2
Thanked 81 Times in 81 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-10-2008, 03:14 PM
ICTADVIS ICTADVIS is offline
Junior Member
 
Join Date: Nov 2007
Location: Scotland
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding Google Analtyics to Oscommerce shopping cart

Hi Lawrence

Your reply is very much appreciated and I will look towards making these changes in this OScommerce platform of my clients site. This is the only site left operating OScommerce as most of my either clients opted to move over to Zencart when it became available, although it does not go without its challenges also when it comes to programming it with Analytics.

Another question for you, if you don't mind is to ask about your preferred code use. Are you sticking with Google's urchin code or have you opted to include their revised code for sites you are now doing?

Many thanks again for your original response and in advance should you manage to get time to respond to this thread
__________________
ICTADVIS
www.ictadvisor.com
info@ictadvisor.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-10-2008, 03:21 PM
Lawrence Lawrence is online now
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,220
Thanks: 2
Thanked 81 Times in 81 Posts
Default

I use the new code now. It has a built in SLL switch and adds a bit of extra functionality to GA.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-10-2008, 03:27 PM
ICTADVIS ICTADVIS is offline
Junior Member
 
Join Date: Nov 2007
Location: Scotland
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Google Analytics Code

Hi Lawrence
No financial meltdown affecting our industry then, if both of us are at our desks on a Saturday afternoon, someone must be paying us both

Thanks for the swift response and that just reaffirms we are selecting the right code all the time to paste into sites since Google started to offer it.

I better be off now and let my other half know I am alive and well!!

Enjoy!
__________________
ICTADVIS
www.ictadvisor.com
info@ictadvisor.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-10-2008, 03:32 PM
Lawrence Lawrence is online now
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,220
Thanks: 2
Thanked 81 Times in 81 Posts
Default

Quote:
Originally Posted by ICTADVIS View Post
Hi Lawrence
No financial meltdown affecting our industry then, if both of us are at our desks on a Saturday afternoon, someone must be paying us both
Not quite at my desk, I'm lying on my bed with a laptop
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
google analytics, oscommerce

LinkBacks (?)
LinkBack to this Thread: http://www.eshopforums.com/f13/how-add-google-analytics-every-page-your-oscommerce-store-106/
Posted By For Type Date
CasBaH's Bookmarks on Delicious This thread Refback 09-10-2008 04:22 PM
javascript code in .php footer? This thread Refback 05-10-2007 01:35 AM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Analytics eCommerce Tracking Module Lawrence PHP/HTML/CSS/JavaScript and Servers 0 30-09-2008 06:55 AM
Google Analytics Problem.. Arkwright Zen Cart & osCommerce 10 14-01-2008 10:01 AM
Google Page Rank Update Lawrence SEO and PPC 6 31-10-2007 03:08 AM
Google is Becoming Wikipedia Without the Talk Page SEOBook SEO and PPC 0 08-10-2007 11:10 AM
google analytics Tinkerbell PHP/HTML/CSS/JavaScript and Servers 1 27-08-2007 04:03 PM

Google

Edible Graphics, Affordable E-Commerce, Web Shops & Custom Form Scripts
Click here for domain name registration and web hosting
tech news, product reviews, the latest home and business technology, the latest in digital imaging


Content Relevant URLs by vBSEO 3.0.0