[x] 🧪 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"}});
[x] 🧪 As guest or not admin. Check woocommerce-google-analytics-integration-js script is loaded the main file
[x] 🧪 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"
[x] 🧪 As guest or not admin. Go to shop and verify page_view is sent
[x] 🧪 Log as admin. None of those scripts should be attached.
3. Check consent
[x] 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"}});
[x] Add a snippet for changing those settings, and verify is being sent in the debugger:
[x] 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
[x] 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
[x] Click on the product image in one of the products and verify that select_content is being triggered.
5. Check blocks (Products Beta) events
Prereqs. Create a page with "Poducts Beta" block on it.
[x] 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
[x] 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
[x] 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.
[x] 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
[x] 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
[x] 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.
[x] 🧪 Go to that page and verify that view_item_list is being triggered for the products in the grid.
[x] 🧪 Click on Add to Cart in one of the products and verify add_to_cart is being triggered.
[x] Click on the product image in one of the products and verify that select_content is being triggered.
8. Check Single product page events
[x] 🧪 In the single product page check that view_item is triggered.
[x] 🧪 In the single product page check that view_item_list is triggered for the related items.
[x] 🧪 Add one of those related items to the cart. Verify add_to_cart is being triggered.
[x] Click on the name of one of those related items. Verify that select_content is being triggered.
[x] 🧪 In the single product page. Add the item to cart. Verify add_to_cart is being triggered.
[x] 🧪 In a variable page. Add the item to cart. Verify add_to_cart is being triggered.
9. Check Cart
[x] 🧪 Open the cart on the side and remove an item. Verify that remove_from_cart event was triggered.
[x] 🧪 Go to the cart page and remove an item. Verify that remove_from_cart event was triggered.
10. Check Purchase
[x] 🧪 Add an item to the cart. And go to Checkout. Verify that begin_checkout was triggered.
[x] 🧪 Place the order. Verify that purchase was triggered.
11. Disabling events
[x] Go to Settings and uncheck everything in "Event Tracking" section.
[x] Verify thatview_item_list event is not being triggered anymore.
[x] Verify that add_to_cart event is not being triggered anymore.
[x] Verify that select_content event is not being triggered anymore.
[x] Verify that view_item event is not being triggered anymore.
[x] Verify that remove_from_cart event is not being triggered anymore.
[x] Verify that begin_checkout is not triggered.
[x] Verify that purchase is not triggered.
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;
}
);
0. Installation 🧪
1. Settings
Settings
( WooCommerce → Settings → Integration → Google Analytics )G-28QSQJCS9D
2. Check scrips and data is loaded 🧪
google-tag-manager-js
script is loading async https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXwoocommerce-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"}});
woocommerce-google-analytics-integration-js
script is loaded the main filewoocommerce-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"
page_view
is sent3. Check consent
4. Check the default theme shop page events
view_item_list
is being triggered for the products in the grid.add_to_cart
is being triggered.select_content
is being triggered.5. Check blocks (Products Beta) events
Prereqs. Create a page with "Poducts Beta" block on it.
view_item_list
is being triggered for the products in the grid.add_to_cart
is being triggered.select_content
is being triggered.6. Check blocks (All Products) events
Prereqs. Create a page with "All Products" block on it.
view_item_list
is being triggered for the products in the grid.add_to_cart
is being triggered.select_content
is being triggered.7. Check triggers (Classic pages) events
Prereqs. Create a page with [products] shortcode on it.
view_item_list
is being triggered for the products in the grid.add_to_cart
is being triggered.select_content
is being triggered.8. Check Single product page events
view_item
is triggered.view_item_list
is triggered for the related items.add_to_cart
is being triggered.select_content
is being triggered.add_to_cart
is being triggered.add_to_cart
is being triggered.9. Check Cart
remove_from_cart
event was triggered.remove_from_cart
event was triggered.10. Check Purchase
begin_checkout
was triggered.purchase
was triggered.11. Disabling events
view_item_list
event is not being triggered anymore.add_to_cart
event is not being triggered anymore.select_content
event is not being triggered anymore.view_item
event is not being triggered anymore.remove_from_cart
event is not being triggered anymore.begin_checkout
is not triggered.purchase
is not triggered.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.
wp plugin install wp-consent-api --activate
wp plugin install autoptimize --activate
view_item_list
is being triggered with all "Denied" consent.wp_set_consent('statistics', 'allow')
. Verify thatanalytics_storage
consent was updated.add_to_cart
is being triggered with updated consent.view_item_list
is being triggered with "Granted" consent.wp_set_consent('marketing', 'allow')
. Verify thatad_storage, ad_user_data, ad_personalization
consent was updated.add_to_cart
is being triggered with updated consent.view_item_list
is being triggered with all "Granted" consent.wp_set_consent('statistics', 'deny')
. Verify thatanalytics_storage
consent was updated.add_to_cart
is being triggered with updated consent.view_item_list
is being triggered with "Denied"analytics_storage
consent.