How to Add Google Analytics Code in PrestaShop
Tracking your PrestaShop store’s performance is fundamental to growing your sales. The best way to get a clear picture of what’s working - and what isn’t - is by using Google Analytics. This article will provide a step-by-step guide to adding Google Analytics 4 to your PrestaShop site, covering both the simple module approach for most users and the manual method for those who need a custom setup.
Why Connect Google Analytics to Your PrestaShop Site?
Before diving into the "how," it's worth understanding the "why." Integrating Google Analytics with your e-commerce store transforms guesswork into a data-driven strategy. It allows you to answer the critical questions that every store owner has:
- Who are my visitors? Understand customer demographics like age, location, and gender, as well as the devices (desktop vs. mobile) they use to shop on your site.
- How do they find me? See which channels drive the most traffic. Are customers coming from organic search, your Facebook ads, a specific email campaign, or direct links? This helps you know where to invest your marketing budget.
- What do they do on my site? Track which pages and products are most popular, how long people stay on your site, and the path they take from landing page to checkout.
- How do I improve conversions? With e-commerce tracking, you can analyze your sales funnel to see where shoppers drop off. Are they abandoning their carts at the shipping page? Knowing this helps you identify friction points and optimize the user experience to increase sales.
In short, Google Analytics is like a detailed map of your customers' journey through your store. Without it, you're navigating blind.
Getting Your Google Analytics 4 Measurement ID
Regardless of which installation method you choose, you first need a Google Analytics 4 property for your PrestaShop site. From this property, you'll get a unique "Measurement ID" that connects your store to your GA4 account.
If you already have a GA4 property set up for your store, you can skip to grabbing your Measurement ID. If you're starting from scratch or still have an old Universal Analytics account, follow these steps.
Step 1: Create a Google Analytics Account
Head over to the Google Analytics website and sign in with your Google account. If you don't have an Analytics account yet, you'll be prompted to create one.
Step 2: Create a New GA4 Property
In the admin area, click on the blue "Create" button and select "Property."
- Property name: Give your property a clear name, such as "My PrestaShop Store."
- Reporting time zone & Currency: Set these to match your store's primary location and currency.
Click "Next" and fill out the optional business information.
Step 3: Set Up a Web Data Stream
Analytics needs to know where it's collecting data from. You'll be prompted to "Choose a platform." Since you're tracking a website, select "Web."
Enter your PrestaShop store's URL (e.g., www.mystore.com) and create a name for the stream (e.g., "PrestaShop Web Store Stream"). Once you're done, click "Create stream."
Step 4: Find and Copy Your Measurement ID
After creating the stream, you'll land on the "Web stream details" page. In the top-right corner, you will see a Measurement ID that starts with "G-" followed by a series of numbers and letters. This is the key piece of information you need.
Click the copy icon next to it and save it somewhere handy. You’ll need it in the next section.
Method 1: Using the PS Google Analytics Module (Recommended)
For the vast majority of PrestaShop users, the easiest and safest way to connect Google Analytics is by using a dedicated module. Many PrestaShop versions come with an official "PS Google Analytics" module pre-installed or available for free in the Module Catalog. This method eliminates the need to edit code and, most importantly, often enables enhanced e-commerce tracking automatically.
Step 1: Go to the Module Manager
Log in to your PrestaShop back office. In the left-hand navigation menu, go to Improve > Modules > Module Manager.
Step 2: Find the Google Analytics Module
Use the search bar on the Module Manager page to search for "Google Analytics." You should see the "PS Google Analytics" module. If it's not already installed, you'll see an "Install" button next to it. If it is, you'll see a "Configure" button.
Step 3: Install and Configure the Module
Click "Install" if required, then click "Configure."
The configuration page is refreshingly simple. Here’s what you need to do:
- Google Analytics Tracking ID: This is where you paste the Measurement ID (the one starting with "G-...") that you copied from your GA4 account earlier.
- Enable User ID Tracking: Toggling this on can give you more accurate user counts by tracking logged-in users across different devices. It's generally a good idea to enable it.
That's it! Click "Save" to apply the settings.
Step 4: Verify the Installation
Never assume everything is working without checking. The best way to confirm the setup is with the realtime report in Google Analytics.
- Open your GA4 account and navigate to Reports > Realtime.
- In a separate, incognito browser window, open your PrestaShop store and browse a few pages.
- Look back at your GA4 Realtime dashboard. Within a minute or two, you should see yourself appear as at least one user on the map and in the "Users in Last 30 Minutes" card.
If you see your activity, you're all set! Analytics is now successfully tracking visitors on your store.
Method 2: Manually Adding the Google Analytics Tracking Code
This method involves editing your store's theme files. It is best suited for experienced users or situations where a module cannot be used. Warning: Editing theme files directly can break your site if not done correctly. Always make a backup of your files before making any changes. If you are comfortable doing so, it’s best practice to use a child theme for these types of modifications so your changes aren't lost during a theme update.
Step 1: Get the Full GA4 Tracking Code (gtag.js snippet)
For this method, the Measurement ID alone isn't enough. You need the full JavaScript code snippet.
- In your GA4 account, go to Admin (the gear icon in the bottom left).
- Under the Property column, click on Data Streams and select your web stream.
- Scroll down to the "View tag instructions" section and click it.
- On the "Installation instructions" tab, select "Install manually."
GA4 will provide a block of JavaScript code. It will look something 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>Click the copy icon to copy the entire code block.
Step 2: Access and Edit Your Theme's header.tpl File
The Analytics tracking code needs to be placed within the <head> tags of your website's HTML so it loads on every single page. In PrestaShop, the file that controls this section is typically located at:
/themes/[your-theme-name]/templates/_partials/header.tpl
You can access this file either by connecting to your server with an FTP client (like FileZilla) or by using the File Manager in your hosting account's cPanel.
Navigate to the file path above and open header.tpl in a text editor.
Step 3: Paste the Code and Save
Scroll through the header.tpl file until you find the closing </head> tag. Just before this tag, paste the entire Google Analytics code snippet that you copied.
Save the file and, if you used FTP, re-upload it to your server, overwriting the old version. Be sure to clear your PrestaShop cache afterward to ensure the changes take effect.
Step 4: Verify the Installation
Follow the same verification steps as in Method 1: open your GA4 Realtime report, browse your store in an incognito window, and confirm that your activity shows up. You can also use your browser's "View Page Source" feature on your store's homepage to check that the GA4 script is present in the <head> section.
Important Caveats of the Manual Method
While this method works for basic visitor tracking, it has a significant limitation: it does not track e-commerce data automatically. You will be able to see page views and user sessions, but you won't see valuable data like sales, product views, or add-to-cart events. Setting up e-commerce tracking manually requires a much more complex implementation involving data layers, which is why the module method is strongly recommended for almost everyone.
Final Thoughts
Adding Google Analytics to a PrestaShop store is a critical step for understanding your customers and growing your business. For most merchants, using the dedicated module is the best path forward, as it simplifies the process and unlocks powerful e-commerce reporting with just a few clicks. With this data, you'll be able to optimize your marketing efforts and create a better shopping experience for everyone.
Once you have data flowing into your Analytics account, the next challenge is deciphering it all to find actionable insights. Instead of getting lost in endless reports, we created a way to get faster answers by just asking questions in plain English. For connecting all your marketing and sales data (like Google Analytics, Google Ads, and even Shopify) into one place and getting instant dashboard builds, a tool like Graphed can save you hours of manual reporting work each week.
Related Articles
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.
How to Create a Photo Album in Meta Business Suite
How to create a photo album in Meta Business Suite — step-by-step guide to organizing Facebook and Instagram photos into albums for your business page.