Skip to content

Commit

Permalink
Merge pull request #1740 from WordPress/fix/woocommerce-wwo-integration
Browse files Browse the repository at this point in the history
Fix tracking events like add_to_cart in WooCommerce integration
  • Loading branch information
westonruter authored Dec 14, 2024
2 parents fb9769e + 8c49359 commit ad6a211
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions plugins/web-worker-offloading/third-party/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ function plwwo_woocommerce_configure( $configuration ): array {
$configuration['forward'][] = 'dataLayer.push';
$configuration['forward'][] = 'gtag';

$configuration['mainWindowAccessors'][] = 'wp'; // Because woocommerce-google-analytics-integration needs to access wp.i18n.
$configuration['mainWindowAccessors'][] = 'ga4w'; // Because woocommerce-google-analytics-integration needs to access window.ga4w.

return $configuration;
}
add_filter( 'plwwo_configuration', 'plwwo_woocommerce_configure' );

plwwo_mark_scripts_for_offloading(
// Note: 'woocommerce-google-analytics-integration' is intentionally not included because for some reason events like add_to_cart don't get tracked.
array(
'google-tag-manager',
'woocommerce-google-analytics-integration',
'woocommerce-google-analytics-integration-gtag',
)
);

0 comments on commit ad6a211

Please sign in to comment.