Home » Ecommerce Analytics » GA4 Setup

Google Analytics 4 Setup for Ecommerce: Complete Configuration Guide

Setting up Google Analytics 4 for your online store requires creating a property, installing the tracking code, enabling enhanced ecommerce events, marking purchases as key events, and filtering out internal traffic. The entire process takes about 30 to 45 minutes and gives you free, enterprise-grade analytics covering traffic sources, customer behavior, conversion funnels, and revenue attribution across every marketing channel you use.

Before You Start

You need a Google account, which you likely already have if you use Gmail, Google Ads, or Google Search Console. You need admin access to your ecommerce platform where you can install tracking codes or configure integrations. And you need to know your store's primary URL, default currency, and time zone. If you are setting up GA4 for a store that previously used Universal Analytics, note that GA4 is a completely separate system with different data models and reports. Universal Analytics data does not transfer to GA4, so treat this as a fresh start regardless of your previous setup.

GA4 uses an event-based data model where every user interaction is recorded as an event with associated parameters. A pageview is an event. An add-to-cart action is an event. A completed purchase is an event with parameters for transaction ID, revenue, tax, shipping, and each item purchased. This model is more flexible than the old session-based model, but it means GA4 reports look and work differently than what Universal Analytics users remember. The adjustment period is worth it because event-based tracking captures far more useful ecommerce data.

Step-by-Step Setup

Step 1: Create your GA4 property.
Go to analytics.google.com and sign in. If you have never used Google Analytics, you will be prompted to create an account first, then a property. If you already have an account, click the Admin gear icon in the bottom left, then click Create Property. Enter your store name, select your reporting time zone (use your local business time zone so daily reports align with your business day), select your currency, and choose your industry category. Click Create to generate the property.
Step 2: Create a web data stream.
After creating the property, GA4 prompts you to set up a data stream. Select Web, enter your store's full URL including https://, and give the stream a name like "Main Website." Enable Enhanced Measurement, which automatically tracks page views, scrolls, outbound clicks, site search, and file downloads without any additional code. Click Create Stream, and GA4 will display your Measurement ID (format: G-XXXXXXXXXX). Copy this ID because you need it for the platform installation step.
Step 3: Install the tracking code on your ecommerce platform.
The installation method depends on your platform. In Shopify, go to Online Store, then Preferences, and paste the Measurement ID in the Google Analytics section. Make sure the "Use Enhanced Ecommerce" checkbox is enabled. In WooCommerce, install the official Google Analytics for WooCommerce plugin from the WordPress plugin repository, activate it, and enter your Measurement ID in the plugin settings. For BigCommerce, go to Advanced Settings, then Web Analytics, and paste the Measurement ID. For custom-built stores or platforms without native integration, paste the gtag.js code snippet from your GA4 data stream settings into the head section of every page on your site.
Step 4: Enable enhanced ecommerce event tracking.
Enhanced ecommerce tracking sends the specific events that make GA4 useful for online stores: view_item (when a customer views a product page), add_to_cart (when they add a product), begin_checkout (when they start checkout), add_payment_info (when they enter payment details), and purchase (when the transaction completes). In Shopify, these events are sent automatically once GA4 is connected. In WooCommerce, enable them in the Google Analytics plugin under the Ecommerce tab. Verify events are firing by visiting your store, viewing a product, adding it to cart, and checking the GA4 Realtime report under the Events section. You should see each event appear within seconds of triggering it.
Step 5: Mark purchase as a key event.
In GA4, go to Admin, then Key Events (previously called Conversions). Find the "purchase" event in the list and toggle it on as a key event. This tells GA4 to treat purchases as your primary conversion, which affects how attribution models distribute credit and how conversion reports are calculated. You can also mark add_to_cart and begin_checkout as key events if you want to track micro-conversions in your funnel reports. Key events are what GA4 uses to evaluate traffic quality and marketing channel effectiveness.
Step 6: Filter out internal traffic.
Your own visits to your store inflate session counts and deflate conversion rates because you browse without buying. In GA4, go to Admin, then Data Streams, select your web stream, and click Configure Tag Settings. Under Define Internal Traffic, click Create Rule, name it "Office and Home," set the traffic_type value to "internal," and add your IP addresses using the "IP address equals" condition. Then go to Admin, Data Settings, Data Filters, and ensure the Internal Traffic filter is set to Active. You can find your current IP address by searching "what is my IP" on Google.
Step 7: Link Google Ads and Search Console.
In GA4 Admin, scroll to Product Links and click Google Ads Linking if you run paid search campaigns. This connection allows GA4 conversion data to flow into Google Ads for campaign optimization, and it allows Google Ads cost data to appear in GA4 reports so you can calculate return on ad spend. Similarly, link Google Search Console to see organic search queries, click-through rates, and average positions directly in your GA4 reports under Acquisition. These links take 2 minutes each and are essential for SEO and paid advertising analysis.

Essential GA4 Configuration Settings

Data retention: GA4 defaults to 2 months of event-level data retention, which limits your ability to create custom reports looking back more than 2 months. Go to Admin, Data Settings, Data Retention, and change it to 14 months. This does not affect the standard reports which always show historical data, but it does affect the Explore section where you build custom analyses.

Cross-domain tracking: If your store uses a separate domain for checkout (common with some platforms), you need cross-domain tracking so GA4 treats the journey as one continuous session. Go to your web stream settings, click Configure Tag Settings, then Configure Your Domains, and add both domains. Without this, every customer who moves from your store domain to your checkout domain appears as a new "referral" session, making your traffic source data useless.

Google Signals: Enable Google Signals in Admin, Data Settings, Data Collection to activate cross-device tracking and demographics reporting. When enabled, GA4 can recognize the same user across devices if they are signed into Google, giving you more accurate user counts and understanding of cross-device purchase journeys. The tradeoff is that GA4 may apply data thresholds (hiding small numbers for privacy), but the improved accuracy is worth it for most stores.

Referral exclusions: Add your payment gateway domains (paypal.com, checkout.stripe.com, etc.) to the referral exclusion list in your tag configuration settings. Without this exclusion, customers who are redirected to PayPal for payment and then back to your store appear as "referral" traffic from PayPal, incorrectly attributing the sale to PayPal instead of the actual marketing channel that brought the customer to your store.

Verifying Your Setup

After completing the setup, verify that everything works correctly before relying on the data for decisions. Open your store in a browser (use incognito mode or a device not excluded by your internal traffic filter). Browse to a product page, add it to your cart, proceed to checkout, and if possible, complete a test purchase. In GA4's Realtime report, you should see each event fire in sequence: page_view, view_item, add_to_cart, begin_checkout, and purchase. If any event is missing, the ecommerce tracking for that step is not configured correctly.

Also check the Ecommerce Purchases report (under Reports, Monetization, Ecommerce Purchases) after 24 to 48 hours of live traffic to confirm that product names, prices, and transaction values are being captured correctly. Compare the purchase count and revenue in GA4 to your ecommerce platform's native reports for the same period. Small discrepancies of 5% to 10% are normal due to timing differences and bot filtering, but larger gaps indicate a tracking problem that needs investigation.

The GA4 DebugView (Admin, DebugView) shows events in real time with full parameter details, making it the best tool for troubleshooting specific tracking issues. To use it, install the Google Analytics Debugger Chrome extension, enable it, and browse your store. Every event and its parameters will appear in DebugView, letting you verify that product names, prices, quantities, and transaction IDs are being captured with the correct values.

Platform-Specific Notes

Shopify: Shopify's native GA4 integration handles most ecommerce events automatically, but it does not send the view_cart event. If you need complete funnel tracking, consider using a Shopify app like Analyzify or Google Tag Manager for more granular event control. Shopify also fires the purchase event on its own hosted checkout page, so make sure your GA4 Measurement ID is entered in the Shopify Checkout settings, not just the Online Store preferences.

WooCommerce: The official Google Analytics for WooCommerce plugin handles standard ecommerce events, but advanced configurations like enhanced conversion tracking or custom event parameters may require Google Tag Manager. If you use a WooCommerce checkout plugin that replaces the default checkout flow, verify that ecommerce events still fire correctly because third-party checkout modifications sometimes break the analytics integration.

BigCommerce: BigCommerce's built-in GA4 support covers basic ecommerce events. For full enhanced ecommerce tracking including checkout step events, you may need to use the BigCommerce data layer with Google Tag Manager. BigCommerce's checkout is hosted on a subdomain (checkout.yourdomain.com), so configure cross-domain tracking as described above to maintain session continuity.

What to Do After Setup

With GA4 properly configured, wait at least 2 weeks before drawing any conclusions from the data. During this period, GA4 is calibrating its machine learning models, building audience segments, and establishing baselines. Use this time to familiarize yourself with the GA4 interface, explore the standard reports, and identify the 3 to 5 reports you will check most frequently.

Your next steps should include setting up conversion tracking for paid advertising channels, building a custom analytics dashboard that shows your most important metrics in one view, and learning to interpret your core ecommerce KPIs using the data GA4 now collects. If you run Google Ads, import your GA4 key events into Google Ads as conversions so the platform can optimize your campaigns based on actual purchase data rather than just clicks.