How to Configure Google Analytics API PrestaShop

Cody Schneider8 min read

Setting up a PrestaShop store is a huge first step, but understanding how customers interact with it is what truly drives growth. To do that, you need to connect your store to Google Analytics, the gold standard for web analytics. This article will guide you through the process of configuring the Google Analytics API connection for your PrestaShop store, step by step.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why Connect Google Analytics to Your PrestaShop Store?

Before jumping into the "how," it's worth understanding the "why." Connecting Google Analytics to PrestaShop isn't just about tracking visitor counts, it’s about unlocking a complete view of your customers' journey. This connection allows you to go from guessing to knowing.

Here’s what you gain:

  • Understand Shopper Behavior: See which pages are most popular, how long people stay, and where they tend to leave your site. This helps you identify popular products and pinpoint areas of your store that might need improvement.
  • Track E-commerce Performance: This is the big one. With a proper setup, you can track key metrics like conversion rates, total transactions, revenue, and average order value directly within Google Analytics.
  • Identify Your Best Traffic Sources: Did that sale come from a Google search, a Facebook ad, or an email campaign? Analytics tells you exactly where your customers are coming from, so you know where to focus your marketing budget.
  • Optimize Your Sales Funnel: See how many people add products to their cart but don’t complete the purchase. Identifying where shoppers drop off in the checkout process gives you clear opportunities for optimization.

Today, this means setting up Google Analytics 4, Google's latest version. Unlike its predecessor which was session-based, GA4 is event-based, making it far more powerful for tracking specific user actions like clicks, scrolls, form submissions, and most importantly for you, e-commerce events like add_to_cart and purchase.

What You’ll Need Before You Start

To ensure a smooth setup, let's get a couple of things in order first. You won't need much, but having these ready will make the process much faster.

  1. A Google Analytics 4 Property: If you're new to Google Analytics, you’ll need to create an account and a GA4 property for your store. If you already have an older Universal Analytics property, it's time to create a new GA4 property, as Universal Analytics no longer processes new data. During setup, you'll be given a "Measurement ID," which looks something like G-XXXXXXXXXX. This ID is the key to connecting your store.
  2. Admin Access to PrestaShop: You'll need to be able to log into your PrestaShop back office with an administrator account that has permissions to install and configure modules or edit theme files.

Method 1: Use a PrestaShop Module (The Recommended Way)

For the vast majority of store owners, using a dedicated module is the simplest, safest, and most effective way to integrate Google Analytics. These modules are specifically designed to bridge the gap between PrestaShop and GA4, often including one-click setups for advanced e-commerce tracking that would be incredibly complex to implement manually.

While the exact interface can vary between modules, the general process is very consistent.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 1: Find and Install a Module

From your PrestaShop back office, navigate to the Module Manager. Here, you can search for a module. Good search terms are "Google Analytics," "GA4," or "Google Tag Manager."

You'll likely find both free and paid modules on the PrestaShop Addons Marketplace. While a free module might suffice for basic pageview tracking, a paid module from a reputable developer is almost always worth the investment for an e-commerce store. Paid modules typically offer:

  • Reliable e-commerce event tracking (purchases, add to carts, etc.).
  • Regular updates to keep pace with Google's changes.
  • Dedicated technical support.
  • Additional features like product performance reporting.

Once you’ve chosen a module, either install it directly from the Module Manager or upload it if you downloaded it from the marketplace. After installation, click the "Configure" button.

Step 2: Enter Your GA4 Measurement ID

This is the most important part of the configuration. The module will have a field asking for your "GA4 Measurement ID" or "Google Analytics Tracking ID." This is the G-XXXXXXXXXX ID you got from your GA4 property.

Copy your Measurement ID from your Google Analytics account (Admin -> Data Streams -> select your stream) and paste it into the field in the module’s configuration page.

Step 3: Enable Enhanced Ecommerce Tracking

A good module will have a simple toggle or checkbox to enable "Enhanced Ecommerce Tracking." If you see this option, make sure it is turned on. This is what allows the module to send detailed information about product views, cart activity, and successful purchases from PrestaShop to Google Analytics.

Step 4: Save and Verify

Save your settings in the module configuration. That's typically all it takes. Your store is now sending data to Google Analytics. We will cover how to verify the connection is working in a later section.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Method 2: Manually Add the Tracking Code (Advanced)

If you're comfortable editing code and prefer to avoid using a module, you can add the Google Analytics tracking script directly into your theme's files. This method gives you more control but comes with significant drawbacks: it’s riskier, can be overwritten by theme updates, and will not automatically track e-commerce events.

Heads Up: Before you edit any theme files, always create a backup. A single misplaced character can break your site's layout or functionality. Using a child theme is the best practice for making custom code changes like this.

Step 1: Get Your GA4 Global Site Tag

In your Google Analytics account, go to Admin -> Data Streams and click on your web stream. Under "View tag instructions," you'll find the installation instructions. You're looking for the Global Site Tag (gtag.js) script. It will look like this:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [],
  function gtag(){dataLayer.push(arguments),}
  gtag('js', new Date()),

  gtag('config', 'G-XXXXXXXXXX'),
</script>

Copy this entire block of code. Remember to replace G-XXXXXXXXXX with your actual Measurement ID.

Step 2: Locate your Theme's Header File

You need to paste this script into a file that loads on every page of your site. In PrestaShop, the best place for this is the header.tpl file within your active theme's directory.

You can sometimes edit this via the back office under Design > Theme & Logo, then clicking the "Modify" button for your active theme on a version-specific customization page. However, it's often more reliable to use an FTP client or your hosting file manager to access the file directly.

The typical path is: /themes/your-theme-name/templates/_partials/header.tpl

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 3: Paste the Code and Save

Open the header.tpl file in a text editor. Find the closing </head> HTML tag. Just before this tag, paste your entire Google Analytics Global Site Tag script.

Save the file and upload it back to your server if you were editing it locally. After saving, be sure to clear your PrestaShop cache from the back office (Advanced Parameters -> Performance -> Clear Cache) to ensure the changes are live.

How to Verify the Tracking is Working

Whether you used a module or the manual method, the final step is to confirm that data is being sent correctly to Google Analytics.

The easiest way to do this is with the Realtime report.

  1. Log into your Google Analytics account and navigate to Reports > Realtime.
  2. In a separate, new browser window (ideally an incognito window so you're not logged in as a store admin), open your PrestaShop store's homepage.
  3. Switch back to the GA4 Realtime report. You should see "Users in last 30 minutes" change to at least 1. The report may even show your geographic location.

If you see your activity, the basic tracking is working! If you used a module with e-commerce features, you can go a step further. Add a product to your cart and complete a test purchase to see if those events (like add_to_cart and purchase) appear in the "Event count by Event name" card in the Realtime report.

Final Thoughts

Tying your PrestaShop store to Google Analytics is a non-negotiable step for any serious online business. By using either a dedicated module for ease and power or a manual code injection for basic tracking, you unlock the critical data needed to understand your customers and grow your sales effectively.

But connecting your data sources is just the start. The next challenge is making sense of it all, especially when your customers' journey is split across marketing platforms like Facebook Ads, your PrestaShop store data in GA4, and your email platform. At Graphed, we eliminate that struggle. We allow you to connect all these sources in one place and ask questions in plain English. Instead of spending hours hunting for insights in different tabs, you can just ask, “Show me my top-selling products by traffic source from last month," and get an instant dashboard. We built Graphed to finally make powerful analytics simple, cutting down your reporting time from hours to seconds.

Related Articles