-
Notifications
You must be signed in to change notification settings - Fork 70
General 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
- 🧪 Activating the plugin doesn't cause errors.
- 🧪 Deactivating the plugin doesn't cause errors.
- 🧪 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
- 🧪 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 thewindow.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.
- 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;
} );
- 🧪 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.
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.
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.
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.
- 🧪 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.
- 🧪 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.
- 🧪 Add an item to the cart. And go to Checkout. Verify that
begin_checkout
was triggered. - 🧪 Place the order. Verify that
purchase
was triggered.
- Go to Settings and uncheck everything in "Event Tracking" section.
- Verify that
view_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.
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 in TA that
view_item_list
is being triggered with all "Denied" consent. - In browser dev tools execute
wp_set_consent('statistics', 'allow')
. Verify thatanalytics_storage
consent was updated. - Add item to the cart. Verify that
add_to_cart
is being triggered with updated consent. - Reload the page. Verify in TA that
view_item_list
is being triggered with "Granted" consent. - In browser dev tools execute
wp_set_consent('marketing', 'allow')
. Verify thatad_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 in TA that
view_item_list
is being triggered with all "Granted" consent. - In browser dev tools execute
wp_set_consent('statistics', 'deny')
. Verify thatanalytics_storage
consent was updated. - Add item to the cart. Verify that
add_to_cart
is being triggered with updated consent. - Reload the page. Verify in TA that
view_item_list
is being triggered with "Denied"analytics_storage
consent.