---
title: "Adding Google Analytics to osCommerce"
description: "You can track your osCommerce website statistics with Google analytics. osCommerce has a built in function that allows you to add Google Analytics code to your site. The image to the right shows what..."
url: https://www.inmotionhosting.com/support/edu/oscommerce/adding-google-analytics-to-oscommerce/
date: 2013-04-23
modified: 2022-03-11
author: "InMotion Hosting Contributor"
categories: ["OsCommerce"]
type: post
lang: en
---

# Adding Google Analytics to osCommerce

[![Without analytics code osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-1-no-code.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-1-no-code.png)

You can track your osCommerce website statistics with Google analytics. osCommerce has a built in function that allows you to add *Google Analytics* code to your site. The image to the right shows what the code looks like before adding the *Google Analytics* code. Below are the steps to add your *Google Analytics* to your osCommerce website.

**Note!** You can get your Google Analytics code for free. Please see our article on [Creating a Google Analytics Account](/support/website/google-tools/creating-google-analytics-account/).

## Steps to add Google Analytics code

1. [Log into your osCommerce Admin dashboard](/support/edu/oscommerce/oscommerce-admin-login/).
2. [![Go to the Header Tags osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-2-header-tag.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-2-header-tag.png) Go to **Modules** > **Header Tags**.
3. [![Click Google analytics module osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-3-google-analytics.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-3-google-analytics.png) **Click** *Google Analytics* from the Modules list.
4. [![Edit the module osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-4-edit.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-4-edit.png) **Click** the *Edit* button on the right hand side.
5. [![Add code to the module osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-5-add-code.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-5-add-code.png) **Add** the *Google Analytics* ID in the *Google Analytics* ID box. If you do not know how to get your ID you can get it from the code at Google. Your *Google Analytics* code should look similar to the code below. The *XXXXX-Y* indicates the property ID. osCommerce will need the whole ID like *UA-XXXXX-Y*. <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-Y']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> **Save** the Changes. [![Google Analytics code in head section osCommerce](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-6-with-code.png)](/support/wp-content/uploads/2013/04/edu_oscommerce_301_google-analytics-6-with-code.png) osCommerce will create the *Google Analytics* code for you. Once you save the changes you will see the code in your head section like the snapshot to the right.
