Integrating with Google Analytics

How do I get analytics data for my store?

One of the most popular analytics tracking services is Google Analytics. Other excellent competing tools include Fathom Analytics and Piwik/Matomo.

Basic snippet installation

These services will provide you with a “javascript snippet” to insert onto your site.

The simplest way to do this is to create a new file called

/includes/template/YOURTEMPLATENAME/jscript/jscript_piwik_analytics.js (or rename for your desired service)

and paste the javascript snippet code inside it.

Google Tag Manager

See /user/running/external_javascript_services/ for information about Tag Manager.

Advanced Integration To Provide Calculated Data

If you need to do some data queries or numeric calculations, you will need to change the .js extension in the above file to .php and then you can write PHP code intertwined with the javascript code.

Commonly-requested data which you can incorporate is explained in Integrating Sales/Analytics/Affiliate Tools

Advanced Google E-Commerce Analytics

An Advanced Ecommerce Analytics plugin exists to feed Google’s ecommerce-specific analytics data with sales numbers from your store. It may require some custom coding changes to suit your store’s unique products, but it’s a handy starting point.




Still have questions? No problem! Just 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 October 7, 2020 by Chris Brown (449e840).