How to Integrate Google Analytics 4(GA4) with Shopware 6
1. Introduction
Understanding how customers interact with your online store is essential for success in the modern digital world. Google Analytics 4 (GA4), the most recent version of Google’s analytics platform, offers powerful tools for tracking, evaluating, and enhancing user behavior. No matter how big or small your Shopware 6 business is, you can use GA4 to make data-driven decisions that improve user experience and boost sales.
This guide is designed to help Shopware 6 users integrate Google Analytics 4 into their store, regardless of your level of development experience. We’ll go over your integration options, the significance of GA4, and how to resolve common issues in addition to the technical steps.
2. Why Google Analytics 4? Understanding the Benefits
Before starting any integration, it’s important to understand the advantages of using Google Analytics 4.
Google Analytics 4 is a major improvement over Universal Analytics (UA):
Powered by events Model: GA4 logs every interaction as an event, not just page views. This event-driven architecture offers more adaptable and comprehensive data about user actions, including clicks, scrolls, video plays, and transactions.
Cross-platform tracking: GA4 gives you a complete picture of your clientele by combining data from your website, mobile apps, and other digital platforms into a single property.
Privacy-focused: GA4 was developed with the GDPR and CCPA privacy regulations in mind to help future-proof your analytics. It can operate with few or no cookies and uses more intelligent data controls.
Machine Learning & Insights: By automatically surfacing trends and predictions (like possible revenue from a user segment), GA4 helps you to proactively optimize marketing strategies.
Better eCommerce Support: GA4 is pre-configured to track all eCommerce events, including add-to-cart, product impressions, checkout processes, and purchase conversions.
3. Preparing for Integration: Things to Know and Consider
Current Google Analytics Configuration: If you are currently using Universal Analytics, Google recommends moving to GA4 because UA will stop processing new data on July 1, 2023. GA4 and UA can be used simultaneously during the transition.
Plugins versus Direct Integration: You can either manually add tracking code to your Shopware templates or use third-party Shopware plugins designed for Google Analytics 4 to integrate GA4. Plugins often simplify the process and add additional features like enhanced eCommerce tracking and automated event capture.
Shopware Version Compatibility: Make sure your Shopware 6 version supports the plugin or manual customization methods you plan to use. It might be necessary to update some older Shopware versions for best compatibility.
Shopware Backend and File Access: You will need admin access to Shopware’s backend, theme files, or the ability to create custom plugins if you plan to install GA4 code manually.
4. Creating Your Google Analytics 4 Property
Step 1: Open Google Analytics.
Enter your Google account information to log in at analytics.google.com. To make it easier for you to follow, we have outlined the login procedure in detail here.
This is the first analytics page that you see at first. To continue, click the “Start Measuring” button.
Enter the account name in the required field, then click the “Save” button to save your changes and proceed with the next steps.
Next, with Google Analytics, to display statistics, you need to fill in the Property Name, select the reporting time zone, and choose the currency. Then, proceed by clicking the appropriate button to continue.
Enter the Property Name, reporting time zone, and currency in Google Analytics to view statistics, then click the button to proceed.
At the final step of connecting Google Analytics to Shopware, select “Web” as the platform for a simpler and more efficient setup.
Step 2: Navigate to Admin Settings
Click the gear icon on the bottom left to open the Admin panel.
Step 3: Create a New Property
Under the “Account” column, select your existing Google Analytics account or create a new one if you don’t have one yet.
In the “Property” column, click Create Property.
Enter your Shopware store’s name (e.g., “MyShopwareStore GA4”).
Set your reporting time zone and currency carefully this cannot be changed later easily.
Click Next and fill in business info such as industry category and business size.
Step 4: Setup Data Stream for Website
Choose “Web” as the platform.
Enter your Shopware store’s full website URL (including https://).
Name your stream (e.g., “Shopware 6 Website”).
Click Create Stream.
You will see your Measurement ID in the format G-XXXXXXXXXX. This ID uniquely identifies your Shopware site in GA4 and is necessary for integration.
5. How to Integrate GA4 with Shopware 6: Options Explained
There are two main ways to add GA4 tracking to your Shopware store:
Option A: Using Shopware 6 Admin to Add Your GA4 Tracking ID for Storefront Analytics
Step 1: Open Your Shopware Admin Panel
Log in to your Shopware backend (Admin interface).
Step 2: Navigate to the Storefront Analytics Settings
Go to Settings in the main menu (usually a gear icon). Navigate to the Storefront or Analytics settings in Shopware (typically found under Shop > Storefront > Analytics, depending on your Shopware version). In the Tracking ID field, enter the Measurement ID previously generated in Google Analytics. And then just click on button Save.
Step 3: Configure Optional Settings (if available)
Some versions allow you to activate features like:
• Enhanced eCommerce tracking (automatically record user purchases and product interactions).
• IP anonymization (to safeguard user privacy).
• Custom user action event tracking.
Step 4: Save Your Settings
Click the Save button to apply your changes.
Step 5: Clear Cache and Test
Clear the Shopware cache by going to Settings > Cache & Indexes > Clear cache, or, if you have CLI access, by using the command line cache clear.
To verify tracking is functioning, visit your storefront and use GA4 real-time reports or the Google Tag Assistant Chrome extension.
Why Use This Method?
Easy and code-free: No manual code addition or template editing is required.
Integrated: It functions flawlessly because Shopware has it built in.
Simple to maintain: The admin panel allows you to make changes at any time.
Good for simple tracking requirements: This option is ideal for e-commerce and pageview tracking.
Option B: Manual Code Installation (For Advanced Users and Developers)
If you prefer full control or want to customize tracking, you can insert the GA4 tracking code directly:
<!-- Global site tag (gtag.js) - Google Analytics --> <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>
Replace G-XXXXXXXXXX with your actual Measurement ID.
Open your Shopware 6 theme’s base Twig template, typically found at: custom/plugins/YourTheme/src/Resources/views/storefront/layout/base.html.twig
Insert the code snippet just before the closing </head> tag.
Save your changes and clear Shopware’s cache.
6. Enabling Enhanced eCommerce Tracking: Why and How?
GA4’s enhanced eCommerce tracking lets you measure more than just page views it tracks the full shopping journey with events like:
Product impressions
Product clicks
Product detail views
Add to cart and remove from cart
Begin checkout
Purchase completions
How to Enable in Shopware 6:
If you’re using a plugin, check the settings to activate “Enhanced eCommerce” or “eCommerce Tracking” so these events are recorded automatically.
In manual setups, GA4 events must be dispatched when users perform shopping actions, either by using Shopware’s event system or by writing custom JavaScript. Intermediate coding abilities are needed for this.
7. Testing Your GA4 Integration Thoroughly
Once you install the tracking, it’s essential to verify data flows correctly:
Realtime Reports: In Google Analytics 4, access the Realtime Reports and visit your Shopware site to see your activity reflected instantly.
DebugView: Use GA4’s DebugView for detailed event monitoring.
Google Tag Assistant: Install this Chrome extension to inspect GA4 tags firing on your site.
Test eCommerce Events: Add products to cart, start checkout, and complete test orders to confirm that enhanced eCommerce events are tracked properly.
More Important Events for Shopware in GA4:
page_view
add_to_cart
purchase
user_engagement
session_start
view_item
begin_checkout
view_cart
add_to_wishlist
view_promotion
select_item
refund
checkout_progress
remove_from_cart
8. Additional Tips and Best Practices
Run UA and GA4 in Parallel: Until you are certain that GA4 is completely configured, keep Universal Analytics running alongside GA4 to prevent data loss during the migration.
Maintain Plugin Updates: To guarantee compatibility and security, always use the most recent versions of Shopware and your analytics plugins.
Clear Shopware Cache: To implement changes made to code or plugins, clear the cache.
Verify Privacy Compliance: GA4 offers options for cookie consent and IP anonymization; ensure that your configuration complies with GDPR and other regulations.
Keep a Regular Eye on Reports: Learn to recognize trends, drop-offs, and opportunities by familiarizing yourself with GA4’s reports.
9. Advanced Integration and Future Upgrades
You can easily manage multiple tags, such as Facebook Pixel, Google Ads conversion tracking, and custom scripts, by integrating GA4 with Google Tag Manager (GTM) without having to touch Shopware code again.
New features like automatic event mapping or integration with Shopware’s customer and order data may be added by official GA4 plugins as Shopware develops.
Because GA4 is constantly developing with new features, keep up with Google Analytics announcements.