Google Analytics for WooCommerce

Google introduced Consent Mode in March 2024 to comply with privacy laws in the EEA/UK region. This means website visitors from these regions must now explicitly grant consent for cookies before any analytics tracking occurs.

Without consent, Google Analytics (GA4) and Google Ads won’t capture user data in these locations. The extension does not provide any UI, like a cookie banner, to let your visitors grant consent for tracking. However, it’s integrated with WP Consent API, so you can pick another extension that provides a user interface that meets your needs.

Due to this new requirement, you may notice a discrepancy between your store and Google Analytics/Ads data, as users must grant consent for analytics data to be captured on Google’s platforms.

Google Analytics is a free web analytics tool. The free WooCommerce Google Analytics Integration connects your store to your Google Analytics account to provide basic eCommerce and site analytics and provides valuable metrics on your store’s performance.

For advanced Google Analytics features, we recommend the WooCommerce Google Analytics Pro version.

Not sure if you need the free plugin or the Pro version? Check out our comparison here.

Installation

↑ Back to top
  1. Download the extension from your WooCommerce.com > My Account > Downloads
  2. Go to Plugins > Add New > Upload and select the ZIP file you just downloaded
  3. Click Install Now, and then Activate
  4. Navigate to WooCommerce > Settings > Integrations > Google Analytics (tab) and read the next section to learn how to set up and configure the plugin.

Setup and Configuration

↑ Back to top

Setup Google Analytics 4 (G-)

↑ Back to top

You can configure GA4 by navigating to WooCommerce > Settings > Integration > Google Analytics (tab) and then adding your Google Analytics 4 (GA4) Measurement ID starting with “G-“:

How to find your GA4 measurement ID

  1. Sign in to Google Analytics and click Admin, at the bottom of the left-hand navigation.
  2. In the Data collection and modification column, click Data Streams.
  3. On the Data Streams page, select the data stream that corresponds to your website.
  4. Locate and copy your Measurement ID beginning with G- at the top right of the page. Please note it can take up to 48 hours for the connection to start working.

Tracking Options

  • “Display Advertising” Support: Check this box if you intend to run ads on the Google Display Network and would like these tracked in your analytics account.
  • Track 404 (Not found) Errors: This allows you to find broken or dead links. To see how many times this occurs, go to your Google Analytics account > Behavior > Events > Overview > Error.
  • Purchase Transactions: Track purchases on your site. This requires a payment gateway that redirects to the thank you/order received page after payment. Some popular options that do this are WooPaymentsStripe, Braintree for WooCommerce, PayPal Payments, and Square.
  • Add to Cart Events: Track when customers add a product to their cart. This allows you to see more specific details about your customers’ experience and better understand where they might be dropping off.
  • Remove from Cart Events: Understand what products customers remove from their cart before placing an order.
  • Product Impressions from Listing Pages: Track what lists of products customers see on your website (For example, the primary Shop page and Related Product sections).
  • Product Clicks from Listing Pages: Track what individual products your customers are clicking on.
  • Product Detail Views: Track the products your customers view the full details of.
  • Checkout Process Initiated: Track the moment your customers begin the checkout process.

Setting up Google Analytics goals and funnels

↑ Back to top

You can learn more about setting up conversion events and funnels on Google’s documentation.

Testing Analytics Tracking

↑ Back to top

To test your analytics tracking and ensure it’s sending the correct data to Google, we recommend using the Google Tag Assistant website. While not required, the Tag Assistant Companion Chrome extension can be used alongside it to enable additional troubleshooting features. This tool will analyze the tracking code on your page and notify you of any warnings or errors.

To verify analytics tracking with tag assistant:

  1. Visit https://tagassistant.google.com or click the Tag Assistant Companion extension.
  2. Enter your website URL and click “Connect”
  3. On your website, grant consent on the cookies banner.
  4. Return to the Tag Assistant tab and click “Continue”.
  5. Click on the tag ID (GA-xxx for Google Analytics for WooCommerce) and select the “Hits Sent” tab.
  6. On the site tab, simulate user actions like adding products to the cart, initiating checkout, etc. If analytics tracking is working as expected, you should see these events being captured in the Tag Assistant’s “Hits Sent” tab.

Keep the following points in mind:

  • Pageviews are not tracked for logged-in admin users (so make sure you are logged out)
  • Multiple tracking code instances on the same page can cause issues
  • Tracking can take a while to show up in your Google Dashboard (it’s recommended to wait 24 hours or try the real-time tracking reports)
  • Any JavaScript errors on the page could prevent tracking from occurring. You can use your browser’s developer tools to check if any errors are showing up in the console.
  • Confirm there are no browser extensions or ad blockers that might block the tracking. Disable these tools if necessary to ensure accurate tracking.
  • If you experience any warnings or errors, or if multiple tracking instances are found on your page, the best way to identify the source is to perform a conflict test. Here’s a detailed guide on how to do a conflict test.

Cookie banners, Consent mode, and analytics tracking

↑ Back to top

Consent mode facilitates the communication of visitors’ cookie consent preferences to Google tags. To comply with privacy laws, users in the EEA, UK, and Switzerland must grant cookie consent before analytics tracking is activated. To implement cookie consent, we recommend using one of Google’s recommended CMPs that offers a WordPress plugin compatible with the WP Consent API. Each of those extensions may require additional setup or registration.

For analytics data to be sent to Google Analytics, your consent mode integration must update the consent states after visitors grant consent. You can follow Google’s guide to test if the consent state is correctly updated. If you find the consent state is not updated by your cookie plugin, please contact the plugin’s developers for assistance in ensuring compatibility with Google Analytics for WooCommerce or with WP Consent API.

Frequently Asked Questions

↑ Back to top

How can I Set up cross-domain measurement?

↑ Back to top

If you’re tracking multiple domains or tracking subdomains, we recommend reviewing Google’s documentation on setting up cross-domain measurement.

GA4W overwrites the consent mode defaults set by another extension

↑ Back to top

If the additional CMP extension you chose to provide UI for cookie consent sets its own default state of consent modes, different than the one we set, and you would like to make sure we’ll not overwrite that, you can use the woocommerce_ga_gtag_consent_modes filter to change or disable our setup.

How can I stop firing the page_view event when the page loads?

This is a matter of the default tag config. You can change the send_page_view property using the woocommerce_ga_gtag_config filter.

Hooks & Filters

↑ Back to top

Note: We are unable to provide support for customizations under our Support Policy. If you need to customize a snippet, or extend its functionality, seek assistance from a qualified WordPress/WooCommerce Developer. We highly recommend Codeable, or a Certified WooExpert.

This is an advanced feature please proceed with caution. In case of issues please check the  Testing Analytics section.

Customize the product identifier sent to Google

↑ Back to top

By default, this plugin will use the WooCommerce Product ID to identify products to Google. In some instances it might be necessary to modify the default behaviour. This can be done using the filter woocommerce_ga_product_identifier.

Modify the default consent state for EEA regions

↑ Back to top

The filter woocommerce_ga_gtag_consent_modes gives you the ability to modify the default consent values sent to Google during initialization. For more information see the consent documentation on GitHub.

Use a custom name for the tracking function

↑ Back to top

As is fairly standard when using Google Analytics, there is a global function named gtag which is used to push data. If you need to change the default name, that can be done using the filter woocommerce_gtag_tracker_variable.

Alter the default tag configuration

↑ Back to top

While all configuration changes should be managed via the administration interface, if you need to overwrite the settings used to setup the tracker, that can be done with the filter woocommerce_ga_gtag_config.

Include more than one tracking ID

↑ Back to top

The following hook can be used for adding extra calls to the gtag function on your page:

wp_add_inline_script(
	'woocommerce-google-analytics-integration',
	'gtag( "config", "..." );'
);
Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.