Adding Google Analytics or Google Tag Manager

How do I install JavaScript snippets for 3rd-party tools?

Analytics

There are many analytics services available. One popular one is Google Analytics.

These instructions apply for any vendor, not just Google. Substitute their name in the filename below.

To add VERY BASIC Google Analytics to your site, Google gives you a JavaScript code snippet to install.

The simplest way to install this basic code snippet is:

  • create a new file on your server: /includes/templates/YOURTEMPLATE/jscript/jscript_google_analytics.js
  • paste the snippet from Google in that file
  • done!

(If you’re putting up a snippet for a different vendor, name the file jscript_vendorname.js )

Advanced e-commerce analytics

On the Zen Cart plugins library you will find some ecommerce-specific plugins for Google Analytics which capture product/sale data in greater detail and transmit those to Google as part of their Analytics mining of your site.

If you install one of those plugins, you should delete the “basic” code snippet file mentioned above, else you will get conflicting data. Simply use one or the other, not both.

Google Tag Manager

If you are using Google snippets for things beyond just Analytics, you can install the Google Tag Manager snippet in the following way. Remember: this REPLACES the basic snippet file mentioned for basic analytics above.

NOTE: Using Tag Manager may make the use of Advanced Ecommerce Analytics impossible. Be sure to investigate for yourself.

/includes/templates/YOURTEMPLATE/jscript/jscript_google_tag_manager.js




Still have questions? Use the Search box in the upper right, or try the full list of FAQs. If you can't find it there, head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified March 27, 2021 by Scott C Wilson (960e201).