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.
Steps to add Google Analytics code
- Log into your osCommerce Admin dashboard.
Go to Modules > Header Tags.
Click Google Analytics from the Modules list.
Click the Edit button on the right hand side.
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.
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.