Adding Google Analytics to osCommerce

Without analytics code osCommerce

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

  1. Log into your osCommerce Admin dashboard.
  2. Go to the Header Tags osCommerce

    Go to Modules > Header Tags.

  3. Click Google analytics module osCommerce

    Click Google Analytics from the Modules list.

  4. Edit the module osCommerce

    Click the Edit button on the right hand side.

  5. Add code to the module osCommerce

    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') + '';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })();  </script>

    Save the Changes.

    Google Analytics code in head section osCommerce

    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.

Was this article helpful? Join the conversation!