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.

GoDaddy.com Hosting & Servers 468x60
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 offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 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 offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 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 offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 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 offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 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 offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 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
  #9 (permalink)  
Old 07-12-2008, 02:04 AM
ixtab ixtab is offline
Junior Member
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I added the GA code (new ga.js) version to the end of my footer.php and I can actually verify now on every page when I view source that the code shows just before the </body>, it has my GA ID (basically GA gave me the code pre-typed so I just pasted it as-is) but when I go and browse my website (from 2 locations) and test a few pages and then go to GA the reports still show 0 visitors.

Does it take a long time to start seeing visitors logged in GA or should it have been immidiate?

I tried from both IE and Firefox (2 different IPs/locations) and still no visitors.

Any idea? it has been almost 30 minutes since I plugged the code and still nothing.

Thanks,
Ix.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-12-2008, 07:59 AM
dezina's Avatar
dezina dezina is offline
http://dezina.com
 
Join Date: Sep 2007
Location: England
Posts: 633
Blog Entries: 6
Thanks: 14
Thanked 85 Times in 82 Posts
Default

Am assuming this method will also work if using zencart?
__________________

and
Unusual and Special Gifts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 11-12-2008, 06:06 PM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 Posts
Default

Quote:
Originally Posted by ixtab View Post
Does it take a long time to start seeing visitors logged in GA or should it have been immidiate?
GA doesn't work in real time. They say that it updates every 24hrs, though in practice it updates every 3-4 hrs or so, so you just have to give it some time. I imagine that you've probably worked this out for yourself by now though.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 11-12-2008, 06:10 PM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,345
Thanks: 3
Thanked 87 Times in 87 Posts
Default

Quote:
Originally Posted by dezina View Post
Am assuming this method will also work if using zencart?
SSL switching is built into the new GA code (OP was written before new GA code was available), so as long as you use that and not the older urchin code, all you will have to do is place the code Google gives you in the template footer.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 09-02-2009, 03:29 AM
leroyparker leroyparker is offline
Member
 
Join Date: Feb 2009
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

why not skip all the heartache and install the osCommerce Google Analytics module?

http://www.oscommerce.com/community/.../search,google

These modules work great for my osc and zen-cart stores.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 2 22-10-2009 10:53 PM
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
Home - Top

Edible Graphics, Affordable E-Commerce, Web Shops & Custom Form Scripts
Gadgets online
tech news, product reviews, the latest home and business technology, the latest in digital imaging


Content Relevant URLs by vBSEO 3.0.0