This guide walks you through connecting Google Analytics 4 (GA4) to your WooCommerce store and verifying that purchase events are recorded correctly. You’ll learn how to create a GA4 property, add the tracking code, enable enhanced ecommerce, and test the purchase tracking using both the preview mode and real transactions. By the end, you’ll be able to confirm that revenue and transaction data are flowing into GA4, which is essential for understanding your store’s performance and running effective ad campaigns.
What You’ll Need
- A WordPress site with WooCommerce installed and active.
- Administrator access to your WordPress dashboard.
- A Google account (free) to create a GA4 property.
- Ability to edit your theme’s
header.phpor use a plugin for code insertion (like a header/footer script manager).
Step-by-Step
- Create a GA4 Property
- Go to Google Analytics and sign in.
- Click Admin (gear icon) in the bottom-left.
- In the Property column, click Create Property.
- Enter a name (e.g., “My Store”), select your time zone and currency, then click Next.
- Answer the business questions (industry, size) and click Create.
- Get Your Measurement ID
- In your new property, go to Admin > Data Streams.
- Click Add Stream and choose Web.
- Enter your website URL and stream name, then click Create Stream.
- Copy the Measurement ID (starts with
G-).
- Install the GA4 Tracking Code
- Option A (Recommended): Use a plugin
- Install and activate a plugin like “Insert Headers and Footers” or “GA4 Analytics”.
- Paste the full GA4 tracking snippet (from Data Streams > Web > Tagging Instructions) into the header section.
- Save changes.
- Option B: Manually edit header.php
- Appearance > Theme Editor > Theme Header (header.php).
- Paste the snippet just before the closing
</head>tag. - Update file.
- Option A (Recommended): Use a plugin
- Enable Enhanced Ecommerce in GA4
GA4 automatically tracks ecommerce events, but you need to make sure they’re enabled:
- In GA4, go to Admin > Data Streams > your web stream.
- Click Enhanced Measurement (toggle on).
- Ensure Ecommerce is checked. If not, enable it.
- Save.
- Add WooCommerce to GA4 (via Google Site Kit)
If you’re not using a dedicated GA4 plugin, the easiest way to ensure proper purchase tracking is with Google Site Kit:
- Install and activate the Google Site Kit plugin.
- Go to Site Kit > Setup and connect your Google account.
- Follow the prompts to connect GA4. Site Kit automatically places the tracking code and enables enhanced ecommerce.
- Verify Purchase Tracking
- Use GA4 DebugView
- Install the Google Analytics Debugger Chrome extension.
- Enable the extension, then go to your site and complete a test purchase (or use the preview mode in GA4).
- In GA4, go to Reports > Realtime and you should see the
purchaseevent firing.
- Use GA4 Preview Mode
- In GA4, go to Admin > DebugView.
- Click Start Debugging and follow the instructions to connect your device.
- Complete a purchase on your site while the debugger is active.
- Check Realtime Report
- After a test purchase, go to Reports > Realtime.
- Look for the
purchaseevent and the associated revenue.
- Use GA4 DebugView
- Confirm Data in GA4 Reports
- Wait 24-48 hours for data processing.
- Go to Reports > Monetization > Ecommerce purchases.
- You should see revenue, transactions, and conversion rate.
Common Mistakes
- Using the wrong Measurement ID: Double-check that you copied the G- ID from the correct data stream.
- Not enabling Enhanced Measurement: Without it, GA4 won’t automatically track ecommerce events.
- Placing the tracking code in the footer: The snippet must be in the
<head>section to load correctly. - Testing with a real order: Use a test order or the preview mode to avoid polluting your data.
- Forgetting to clear cache: If you’re using a caching plugin, clear it after adding the tracking code.
Tips
- Use a staging site first: Test the tracking on a staging copy of your site to avoid issues on the live store.
- Keep a backup of header.php: Before editing manually, download a copy so you can restore if something breaks.
- Use Google Tag Manager (optional): If you prefer more control, you can use Tag Manager instead of direct code insertion. It’s more flexible for advanced tracking.
- Monitor for a week: Don’t panic if data doesn’t appear immediately; GA4 can take up to 48 hours to show data.
Troubleshooting
No purchase event in DebugView?
- Check that the GA4 code is present on the checkout page (view page source).
- Ensure Enhanced Measurement is enabled for the stream.
- Clear your browser cache and cookies, then retry.
Purchase event fires but revenue is zero?
- Make sure the currency in GA4 matches your store’s currency.
- Check that the WooCommerce order total is correctly passed via the data layer (if using a plugin).
Data appears in DebugView but not in Realtime?
- Realtime reports can have a few minutes delay; wait and refresh.
- If it’s been over an hour, check that the GA4 code is not blocked by a cookie consent plugin.
Site Kit shows a connection error?
- Disconnect and reconnect your Google account in Site Kit.
- Ensure you have the correct permissions on the GA4 property.
Frequently Asked Questions
Do I need a plugin to set up GA4 on WooCommerce?
No, you can manually add the tracking code, but using a plugin like Site Kit simplifies the process and ensures enhanced ecommerce is configured correctly.
Will GA4 track all WooCommerce orders automatically?
Yes, once enhanced ecommerce is enabled and the tracking code is present, GA4 will automatically track purchases, add-to-cart, and other events. However, you must ensure the code is on all pages.
How long does it take for GA4 to show purchase data?
Typically 24-48 hours. Realtime reports show events immediately, but standard reports take longer to process.
Can I use Google Tag Manager instead of direct code?
Yes, you can use GTM to deploy GA4 and configure ecommerce triggers. It’s more flexible but requires additional setup.
Why is my purchase event not showing in GA4?
Check that the tracking code is on the checkout page, enhanced ecommerce is enabled, and that you’re testing with a real or test transaction. Also, ensure no ad blocker or cookie consent plugin is blocking the request.
Does GA4 track refunds?
GA4 can track refunds if you send a refund event. WooCommerce plugins like Site Kit do not automatically send refunds; you may need to configure that manually or use a dedicated plugin.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- AI for Playwright Locators: Draft, Verify, and Refine
- How to Fact-Check Artificial Intelligence Claims
- Sony Bravia 3 II vs Hisense U6SF Pro: Which to Buy?
- Best Fire Emblem Games Without Monastery Grind
- Are AI Agents Safe for Private Information?
- Best MMORPG Games: Top Picks for Every Play Style