How to add Google Analytics to every page on your osCommerce eCart

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:

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:
if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>






echo tep_display_banner('static', $banner); ?>

}
?>
You need to add your Google code to it like this
PHP Code:
if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>






echo tep_display_banner('static', $banner); ?>

}
?>

That's all there is to it, you now have Google Analytics on every user page of your osCommerce shopping cart.

Posted in |

0 comments: