Skip to content
Eason edited this page Jul 24, 2026 · 42 revisions

For compatibility and general smoke testing

Prereqs:

  • Configured WooCommerce with products, and a valid payment processor (dev Stripe, or cash on delivery option in WC Settings > Payments) so that you can complete checkout.

  • Recommended (you can also check the requests manually tho) to use a debugger tool like Google Analytics Debugger Extension or Tag Assistant (official)

  • ⚠️ Be sure to check the browser console as well as the WP debug log for errors.

  • ⚠️ Make sure there are no Ad blockers in your browser.

  • ⚠️ For testing the tracking try in incognito or without being logged in as admin

  • 🧪 Means the test is covered in E2E tests

0. Installation

  • 🧪 Activating the plugin doesn't cause errors.
  • 🧪 Deactivating the plugin doesn't cause errors.

1. Settings

  • 🧪 Go to Settings ( WooCommerce → Settings → Integration → Google Analytics )
  • 🧪 Confirm it loads OK.
  • 🧪 Confirm that "Product Identification" appears and you can select between Product ID and SKU
  • 🧪 Confirm that "Google Analytics Tracking ID" field appears.
  • 🧪 Add a test tracking like: G-28QSQJCS9D
  • 🧪 Select all: "Display Advertising" Support, Purchase Transactions, Add to Cart Events, Remove from Cart Events, Product Impressions from Listing Pages, Product Clicks from Listing Pages, Product Detail Views, Checkout Process Initiated

2. Check scripts and data is loaded

  • 🧪 As guest or not admin. Check google-tag-manager-js script is loading async https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX
  • 🧪 As guest or not admin. Check woocommerce-google-analytics-integration-gtag-js-after script is loaded with all the gtag config: gtag("config", "G-XXXX", {"track_404":true,"allow_google_signals":true,"logged_in":false,"linker":{"domains":[],"allow_incoming":false},"custom_map":{"dimension1":"logged_in"}});
  • 🧪 As guest or not admin. Check woocommerce-google-analytics-integration-js script is loaded the main file
  • 🧪 As guest or not admin. Check woocommerce-google-analytics-integration-data-js-after script is loaded with all the window.ga4w config: i.e for the cart page: window.ga4w = { data: {"cart":{"items":[{"id":9154,"name":"Incredible Bronze Watch"
  • 🧪 As guest or not admin. Go to shop and verify page_view is sent
  • 🧪 Log as admin. None of those scripts should be attached.

3. Check consent

  • 🧪 Check that the default consent is enabled
    // Set up default consent state.
     for ( const mode of [{"analytics_storage":"denied","ad_storage":"denied","ad_user_data":"denied","ad_personalization":"denied","region":["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IE","IT","LV","LI","LT","LU","MT","NL","NO","PL","PT","RO","SK","SI","ES","SE","GB","CH"]}] || [] ) {
      gtag( "consent", "default", { "wait_for_update": 500, ...mode } );
      }
      gtag("js", new Date());
      gtag("set", "developer_id.dOGY3NW", true);
      gtag("config", "G-XXXXX", {"track_404":true,"allow_google_signals":true,"logged_in":false,"linker":{"domains":[],"allow_incoming":false},"custom_map":{"dimension1":"logged_in"}});
    
  • 🧪 Add a snippet for changing those settings, and verify is being sent in the debugger:
    add_filter( 'woocommerce_ga_gtag_consent_modes', function ( $consent_modes ) {
    		$consent_modes[] =
    			array(
    				'analytics_storage' => 'granted',
    				'ad_storage' => 'granted',
    				'ad_user_data' => 'granted',
    				'ad_personalization' => 'granted',
    				'region' => ['ES'],
    			);
    		return $consent_modes;
    	} );
    

4. Check the default theme shop page events

  • 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
  • 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
  • 🧪 Click on the product image in one of the products and verify that select_content is being triggered.

5. Check blocks (Products Collection) events

Prereqs. Create a page with "Products Collection" block on it.

  • 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
  • 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
  • 🧪 Click on the product image in one of the products and verify that select_content is being triggered.

6. Check blocks (All Products) events

Prereqs. Create a page with "All Products" block on it.

  • 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
  • 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
  • 🧪 Click on the product image in one of the products and verify that select_content is being triggered.

7. Check triggers (Classic pages) events

Prereqs. Create a page with [products] shortcode on it.

  • 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
  • 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
  • 🧪 Click on the product image in one of the products and verify that select_content is being triggered.

8. Check Single product page events

  • 🧪 In the single product page check that view_item is triggered.
  • 🧪 In the single product page check that view_item_list is triggered for the related items.
  • 🧪 Add one of those related items to the cart. Verify add_to_cart is being triggered.
  • 🧪 Click on the name of one of those related items. Verify that select_content is being triggered.
  • 🧪 In the single product page. Add the item to cart. Verify add_to_cart is being triggered.
  • 🧪 In a variable page. Add the item to cart. Verify add_to_cart is being triggered.

9. Check Cart

  • 🧪 Open the cart on the side and remove an item. Verify that remove_from_cart event was triggered.
  • 🧪 Go to the cart page and remove an item. Verify that remove_from_cart event was triggered.

10. Check Purchase

  • 🧪 Add an item to the cart. And go to Checkout. Verify that begin_checkout was triggered.
  • 🧪 Place the order. Verify that purchase was triggered. (Automated for both the checkout block and the classic [woocommerce_checkout] shortcode form; the order confirmation is rendered by the block theme's template in both cases.)

11. Disabling events

  • 🧪 Go to Settings and uncheck everything in "Event Tracking" section.
  • 🧪 Verify thatview_item_list event is not being triggered anymore.
  • 🧪 Verify that add_to_cart event is not being triggered anymore.
  • 🧪 Verify that select_content event is not being triggered anymore.
  • 🧪 Verify that view_item event is not being triggered anymore.
  • 🧪 Verify that remove_from_cart event is not being triggered anymore.
  • 🧪 Verify that begin_checkout is not triggered.
  • 🧪 Verify that purchase is not triggered.

Automated: with every event toggle off, the tracker's enabled-event list is empty and none of the plugin's events reach GA while the tracking scripts still load, including across a full purchase journey (product click-through, product page, cart mutations, checkout, order confirmation); disabling only Add to Cart leaves the other events firing. Visual verification in Tag Assistant remains manual.

12. WP Consent API integration

⚠️ Note: Consent defaults are only set for the EEA regions. If running these tests from a country where defaults are not set then a VPN can be used or alternatively set defaults for your country using the following filter.

add_filter(
	'woocommerce_ga_gtag_consent_modes',
	function ( $consent_modes ) {
		$consent_modes[] =
			array(
				'ad_storage'         => 'denied',
				'ad_user_data'       => 'denied',
				'ad_personalization' => 'denied',
				'analytics_storage'  => 'denied',
				'region'             => array( 'GB' ), // <-- Set your country code here
			);
	return $consent_modes;
	}
);
  • Install & activate WP Consent API extension wp plugin install wp-consent-api --activate
  • (optional) Install Autoptimize plugin wp plugin install autoptimize --activate
  • Go to the shop page. Verify that view_item_list is being triggered with all "Denied" consent (the gcs parameter on the collect request).
  • 🧪 In browser dev tools execute wp_set_consent('statistics', 'allow'). Verify that analytics_storage consent was updated.
  • 🧪 Add item to the cart. Verify that add_to_cart is being triggered with updated consent.
  • 🧪 Reload the page. Verify that the consent state is sent again on page load.
  • 🧪 In browser dev tools execute wp_set_consent('marketing', 'allow'). Verify that ad_storage, ad_user_data, ad_personalization consent was updated.
  • 🧪 Add item to the cart. Verify that add_to_cart is being triggered with updated consent.
  • Reload the page. Verify that view_item_list is being triggered with all "Granted" consent.
  • 🧪 In browser dev tools execute wp_set_consent('statistics', 'deny'). Verify that analytics_storage consent was updated.
  • 🧪 Add item to the cart. Verify that add_to_cart is being triggered with updated consent.
  • Reload the page. Verify that view_item_list is being triggered with "Denied" analytics_storage consent.

The wp_set_consent() allow/deny flows, the consent state sent on page load, and the gcs parameter carried by event hits in both the granting and denying directions are automated in tests/e2e/specs/js-scripts/wp-consent-api.test.js; hits sent while a category is denied still arrive as consent-restricted pings. For visual inspection with Tag Assistant, see the section at the end of this page.

13. Product Identification (SKU)

  • 🧪 Set "Product Identification" to SKU
  • 🧪 View a product with a SKU: view_item reports the SKU as the item ID
  • 🧪 View a product without a SKU: the item ID falls back to #<product id>
  • 🧪 Add to cart on the block storefront (Store API): the SKU is reported

Tag Assistant verification (situational)

Routine regression and compatibility testing rely on the automated E2E assertions against the network requests, which cover the same data Tag Assistant displays. A manual Tag Assistant (or GA4 DebugView) session is still recommended when:

  • Setting up or validating a real store for the first time: real measurement ID, real theme and plugins, ad blockers, and consent tooling are all outside what the test environment represents.
  • Google announces changes to Consent Mode or gtag.js behavior: Tag Assistant shows how Google interprets the sent data (for example whether a hit fired in full or as a cookieless ping), which network-level assertions do not decode.
  • Debugging a merchant report about missing or wrong events.
  • Before a release, as a one-off end-to-end check on a real property: GA4 DebugView confirms the data is interpreted correctly after ingestion, which no client-side check can prove.