Everything About Google Analytics in PrestaShop Store

Everything About Google Analytics in PrestaShop Store

Every store owner knows that tracking purchase information is the most valuable metric related to store success measurement.

But that is not the only thing to track, and I strongly recommend including visitors’ information into account. This includes store page views, unique users, user’s location, behavior, and interactions data.

A lot of website owners are using Google analytics for tracking user-related information. Does PrestaShop work with Google Analytics? PrestaShop has its statistic gathering engine, but store owners could use Google Analytics too. There are multiple ways to add Google Analytics tracking code: modifying the template file and using addon or theme settings.

Let’s explore how to add google analytics code and how to fix some common issues related to tracking visitors.

Add Google Analytics Code Using PrestaShop Addon

The correct and official way to install the Google Analytics tracking code is to use the free Google Analytics module for PrestaShop.

Go to your store back office, click Modules, then the Module Catalog sidebar menu. In the search bar, type google analytics. This will bring lots of addons, so be sure to find the Google Analytics addon made by PrestaShop.

Free Google Analytics Addon for PrestaShop
Free Google Analytics Addon for PrestaShop

Click the large Install button on the bottom.

After installation, you can click configure button at the bottom. Or if you already closed the page, navigate to Modules, click on Module Manager, and in the search bar, type google analytics again - this will bring addons that you have already installed.

Enter the Google Analytics Tracking ID you received for your Google Analytics property in the Settings form.

This form holds a few other options that are worth using.

PrestaShop User ID Tracking in Google Analytics

If you enable this option, PrestaShop will send a User ID to your Analytics report for every tracked record.

It is a valuable option to enable because then you can track purchase funnels. But that deserves another topic.

Anonymize IP in Google Analytics Tracking Code for PrestaShop

If your store is located in the US, but your users visit the store from Europe - you have to comply with GDPR law. That law has strict rules about users tracking. One of these rules includes users’ IP tracking - you are not allowed to keep user IP records.

So the best would be to enable the Anonymize IP option in the Google Analytics PrestaShop addon settings page. This will not send IP addresses, but that won’t hurt any geolocation or any other metric in your Analytics reports.

Google Analytics is smart enough to hash IP addresses and not store them anywhere, making your tracking compliant with GDPR.

Disable Google Analytics in PrestaShop Back Office

Do not track your staff members with google analytics.

Tracking staff members will add additional metrics to your geolocation and will lower down your conversion metrics.

Google analytics on the back office will slow down work for your staff a bit because of tracking.

Your pages reports might include URLs from the back office that you are not interested in at all.

So never enable this option.

How to Test Google Analytics Code in PrestaShop

If you have enabled tracking code, you might want to test if tracking works properly. First, go to Google Analytics and click Real Time. Then refresh your storefront office (landing page/homepage), and you should see stats increase right in your Google Analytics:

Test Google Analytics Tracking Code for PrestaShop
Test Google Analytics Tracking Code for PrestaShop

If you don’t - maybe you have an adblocker running? If so - disable it and try again. Or try again with a different browser if you have (Firefox, Chrome, Edge, Safari).

If nothing shows in the Real Time view after all these steps, you will need to clean up store cache (navigate to the back office, click on Advanced Parameters, Performance page, and there you will find few buttons to cleanup cache). Then repeat test actions.

Add Google Analytics to Header.tpl PrestaShop Theme File

Five or more years ago, it was trendy to insert Google Analytics tracking code directly into the PrestaShop theme files (header.tpl). Of course, you can still do that, but there is no real reason to go this way when we have an official addon for that.

If you still want that, navigate to the header.tpl file in your PrestaShop file system and add entire analytics code between {literal} and {/literal} tags like so:

{literal}
  <script async src="https://www.googletagmanager.com/gtag/js?id=CODE"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gaInit() {
      dataLayer.push(arguments);
    }
    gaInit('js', new Date());
    gaInit('config', 'CODE', { 'anonymize_ip': true });

    function gtag() {
      dataLayer.push(arguments);
    }
  </script>
{/literal}

Be sure to recompile templates or cleanup cache in PrestaShop store back office, Advanced Parameters, Performance page.

PrestaShop Stats vs. Google Analytics

Both a great statistic tools to use. But in PrestaShop Stats, you will see a bit bigger numbers than are in Google Analytics. That is because PrestaShop tracks everything in the backend (server) while Google Analytics does tracking by using JavaScript external code. And adblockers block external codes, so not all users are tracked.

That does not mean that Google Analytics is worse. On the contrary, most marketing and sales companies trust this data much more than actual (accurate) data because Google Analytics is an industry-standard.

PrestaShop Stats Page in the Back Office
PrestaShop Stats Page in the Back Office

And Google Analytics gives lots of options to customize, filter, and analyze reporting. It supports creating different views for different areas of expertise. Marketing teams can have information about users, geolocation, traffic sources, and channels. Sales teams can be only interested in revenue tracking and related metrics.

PrestaShop stats only have metrics filtering, and that makes this tool a bit useless. Furthermore, it does not offer exporting ability (Google Analytics does), making metrics useless if you want to share them outside the PrestaShop store back office.

How to Disable PrestaShop Stats

If you are using Google Analytics for user tracking, it would be the best to disable PrestaShop Stats.

This will speed up your store a bit.

There is no one option to disable PrestaShop stats. Everything in PrestaShop is an addon, so there are addons for stats too.

Navigate to the back office, click Modules, and in Module Manager, enter stats dashboard. Then, disable all addons that have these words in the description of the enabled module.

Disable PrestaShop Stats in the Back Office
Disable PrestaShop Stats in the Back Office

How to Add Google Tag Manager to PrestaShop

Google Tag Manager is a “next level” Google Analytics tracking code. While Google Analytics alone can track your customers’ behavior, Google Tag Manager allows controlling the entire marketing suite for your ecommerce.

With Google Tag Manager, you can add various other tracking codes, like Facebook Pixel. You can also setup Google Analytics Goals and Events.

There is an official and free PrestaShop Addon for Google Analytics tracking code, but no official Google Tag Manager addon exists.

How do I add Google Tag Manager to PrestaShop? The only option right now is to locate header.tpl file in themes folder and add there Google Tag Manager code there.

Conclusion

Google Analytics integration can add some great benefits to your store success tracking. Especially when you have an Ecommerce tracking option enabled in the Google Analytics property settings page.

Ecommerce tracking adds revenue tracking information: conversations and purchase amounts. That is excellent info right on your Analytics report page!