Adding the Google Analytics code to OpenCart 1.5

Google analytics provides in-depth data into who’s visiting your website and what they are doing once they are there. If you have not already set up a Google Analytics account, you’ll need to do so.

  1. Once you have your Google Analytics code log into your OpenCart Dashboard
  2. Go to System > Settings
  3. Choose your store and click “edit
  4. Go to the server tab and scroll to the bottom
  5. Find the Category for Google Analytics Code and paste your code in the text box If you are not familiar how to get your Google Analytics code please see our article on Installing Google Analytics
    opencart_google_analytics
  6. Click “Save

You’ve now added Google Analytics to your OpenCart Website and Google can start collecting data about your website’s visitors. If you need further assistance please feel free to ask a question on our support center website.

Carrie Smaha
Carrie Smaha Senior Manager Marketing Operations

Carrie enjoys working on demand generation and product marketing projects that tap into multi-touch campaign design, technical SEO, content marketing, software design, and business operations.

More Articles by Carrie

17 thoughts on “Adding the Google Analytics code to OpenCart 1.5

  1. Good way to add code Google Analytics for Opencart from 1x – 2x 

    => https://www.obinb.com/2016/05/huong-dan-cach-gan-google-analytics-vao.html

  2. I tried pasting the google analytics java script code under extensions>analytics

    but I am getting the following error

    Undefined index: store_id in /customers/7/a/1/(mydomainname).com/httpd.www/admin/controller/analytics/google_analytics.php on line 13Warning: Cannot modify header information – headers already sent by (output started at /customers/7/a/1/(mydomainname).com/httpd.www/admin/controller/startup/error.php:34) in /customers/7/a/1/(mydomainname).com/httpd.www/system/library/response.php on line 12

    What does this mean and how do I rectify this? Please help

    1. It’s possible you placed the code in a spot that disrupted the PHP code. The error you are seeing is a PHP error.

  3. Hi buddies,

    This is a very simple and easy way to add the google analytics code to opencart and i just did it all like discribed, however when i was thinking that it was simple and fast google comes with “Status: Tracking Not Installed

    Last checked: Apr 12, 2015 7:07:37 AM PDT
    The Google Analytics tracking code has not been detected on your website’s home page. For Analytics to function, you or your web administrator must add the code to each page of your website.”
     
    What can be wrong and what to do?
     
    Thanks in advance,
     
    Vitor
    1. Hello Vitor,

      This seems to be an issue with OpenCart. Arnel mentioned above that there is a thread with a solution for this. Try that and see if that helps. He also provided a link to a plugin that may also help.

      Kindest Regards,
      Scott M

  4. Hi Arnel

    I realised my mistake?!! I just pasted the tracking id not the whole code! no wonder it wasnt picking up. It should work now.

     

    Thanks for your feedback as well. appreciated

     

    Regards

    Pal

  5. I am using OC1.5.6 and I have inserted my GA code in the server tab section, unfortunately Google tells me there is a missing tracking code -> No valid tracking code found for property.

    1. Hello Pal,

      Sorry for the problems with the Google Analytics. Apparently, the problem has also been seen by other OpenCart users. They posted a solution here. There is also a plugin that could make this easier as well. The plugin can be found here.

      Regards,
      Arnel C.

  6. Hi There,

    So pasting the google analytics code into the text box will apply google analytics to the entire website? 

     

    On the Google analytics page it says “This is your tracking code. Copy and paste it into the code of every page you want to track.”

    1. Hello Alex,

      Thank you for your comment. For many Content Managment Systems (CMS), you will just have to add the Google code to the Dashboard, or use a plugin. It will then add the code to the pages.

      Since OpenCart is built in PHP (like many CMS’s), most of the pages are created dynamically. Meaning they are generated as needed, and there is no “static” page to add a tracking code to.

      If you have any further questions, feel free to post them below.

      Thank you,
      John-Paul

  7. Enquiry:

    Why cant I install Google Analytics in my site.
    It keeps on diverting me to error page
    that says:

    Forbidden

    You don’t have permission to access /admin/index.php on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request

    1. Hello Laarnibebe,

      Sorry to hear that you are having a problem with the Google Analytics installation. Usually, when you see an error of this nature it means that the directory (or folder) mentioned in the error has a permission setting that does not allow you to make that change. This could also be a server security rule. You will need to check permissions for that folder and/or consult with your server support team in order to determine why you cannot install the module.

  8. I’m really new to building an online store and articles like these are so useful for a rookie like myself! I created a Google Analytics account and had no clue what to do after that (lol) so I searched for “where to add google analytics code in opencart” and this brilliant article was the 1st hit which I followed. I’m in the final stages of completing my website, and articles like these save me so much time which I can use to finalise my website instead of figuring out “code”.

    Thank you.

    1. No improvement needed. This was the best, most straight-forward instruction and I was able to do it minutes. Thank you so much!!

Was this article helpful? Join the conversation!