How to Install Google Analytics in 5 Minutes
What’s the difference between online and offline shoppers?
You can’t see online shoppers. They’re invisible. And if you can’t see them, you can’t answer the following questions:
- Where are they from?
- What keywords are they using to find your site?
- Which products are they looking for?
- Was all that hard earned cash you spent on advertising really worth it?
Google Analytics will answer all these questions and more. It acts as a spotlight that illuminates your visitors by secretly gathering vital information about them. Vital information that you need to make your store a success.
Here’s how to install it on any osCommerce store in just 5 minutes.
Minute 1. Sign Up for a Google Analytics Account
Visit google.com/analytics and sign up for a free account. If you already have a Google Account (e.g. you use GMail or other Google services) there is no need to create a new one. Simply enter you login details as requested.
Minute 2. Create a Website Profile
Once you have an account, it’s time to let Google know about your site. Find the Add Website Profile button near the top right of the screen and click it.
On the next screen, leave the top radio button set to Add a Profile for a new domain and enter your website URL below. Click Finish.
On the final screen, you are presented with tracking code that will look similar to this:
<script src=”http://www.google-analytics.com/urchin.js” type=”text/javascript”>
</script>
<script type=”text/javascript”>
_uacct=”UA-xxxx-x”;
urchinTracker();
</script>
Copy this code from the browser and paste it into a new text file on your computer. This is so you have easy access to it in future steps.
Minute 3. Add Tracking Code to Your Site
Navigate to your osCommerce store directory and open catalog/includes/footer.php. Paste the tracking code at the very end of this file. Save and close the file.
Why am I doing this? The footer.php file gets included in every single one of your store’s pages. By pasting the tracking code into this one file, it will automatically be inserted into the HTML of all your pages.
Minute 4. Double-Check Your Store
To make sure your tracking code is successfully installed, you need to check the code is present. Browse to the home page of your shop in your favourite browser, then look at the source code (View -> Source in IE6, View -> Page Source in FireFox 2). Scroll to the bottom of the source file and make sure your tracking code is there. If not, re-read Step 3.
Congratulations! Google Analytics is now monitoring your site (and we still have a minute to spare!).
Minute 5. Sit and Wait.
You might be tempted to log straight back into your Analytics account and spy on your visitors. If you do, don’t expect to see much. Google Analytics does not update in real-time. You will have to wait up to 24 hours before you start seeing any tracking statistics.
Now What?
Once Google Analytics has been up-and-running for a few days, you will begin to see it’s power. One of the features I love is the ability to see which keywords people are using to find your site. Take a look. You might be suprised by some of them!
The next step is to begin picking out key snippets of information and using them to your advantage. You could optimise pages for specific keywords, iron out any checkout process stalling points or set monthly S.M.A.R.T. goals based on your store’s current performance.
You’ve got the information. It’s up to you how you use it.
Enjoyed reading this post? Get more delivered directly to you.
Well this works. However, when you go to SSL pages you get prompted with annoying “This page contains both secure and unsecure items” alert! That’s alert after alert during the checkout process. I think u have to put this code inside an “IF” statement to prevent it from appearing in SSL pages.
Analyzer | July 29th, 2007 at 12:12 am
You could do this, but then you would lose tracking on your secure pages.
The best way around this is to use two Google analytics URLs; one for SSL pages and one for non-SSL pages.
Non-SSL: http://www.google-analytics.com/urchin.js
SSL: https://ssl.google-analytics.com/urchin.js
By adding a small amount of PHP code, you can detect if you are on an SSL page or not, and insert the correct Google analytics code.
e.g.
< ?php
if($_SERVER['HTTPS']) {
$url = https://ssl.google-analytics.com/urchin.js;
} else {
$url = http://www.google-analytics.com/urchin.js;
}
?>
Then change the first Google analytics line to:
<script src=”< ?php echo $url; ?>” type=”text/javascript”></script>
NOTE: The $_SERVER[’HTTPS’] variable may not be used on your server. If this is the case, you will have to find another way to detect if you are on an SSL page or not. An alternative might be $request_type == ‘SSL’.
Ed | July 29th, 2007 at 11:28 am
Well according to google you can use SSL code on both secure and nonsecure pages.
http://forums.oscommerce.com/index.php?showtopic=180940
If you want to use both, you can find more solid code in this contribution.
http://www.oscommerce.com/community/contributions,3756
Analyzer | July 29th, 2007 at 4:14 pm
Where do you find catalog/includes/footer.php?
Navigate to your osCommerce store directory and open catalog/includes/footer.php. Paste the tracking code at the very end of this file. Save and close the file.
Jane | November 13th, 2008 at 12:36 am