-
Notifications
You must be signed in to change notification settings - Fork 339
Format WooCommerce Conversion Event Values to Be Decimal Value as Opposed to Whole Cents Only #10974
Description
Feature Description
Recently, we extended the Enhanced Conversion Tracking suite to track event values for addToCarts and purchase events, for users with WooCommerce installed.
At the time, it was thought that Google for WooCommerce sent the values as whole cent values, where 100.00 would become 10000 etc.
Recently, however, users began to open support issues around this, such as #10972
Upon further investigation, it appears as though the values were only temporarily converted to cents by Google for WooCommerce, but converted back to decimal values prior to sending as event data.
Fixes should be made to ensure that event values sent for addToCarts and purchase events are in decimal format, i.e. 100.25.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Total
addToCartandpurchaseevent values - when sent to GA4 - should be formatted with decimal points, and not whole values including cents.
Implementation Brief
- Update
assets/js/event-providers/woocommerce.js- Adapt the Woo addon function https://github.com/woocommerce/woocommerce-google-analytics-integration/blob/ca7907746bfdc3276cd9e91fdeb5adb873f001ba/assets/js/src/utils/index.js#L77 and use it as helper function in the file
- Reference the helper function in the
formatEventDatafunction, to wrap thevalueproperty of theformattedDataobject, and informatProductDatafunction, forpriceproperty of themappedItemobject
Test Coverage
- No updates needed
QA Brief
- Set up Site Kit with GA4 enabled, ensure that conversion tracking is enabled (it should be by default)
- Set up WooCommerce and add a single product with price including cents, i.e 250.75
- Navigate to the Uncategorised archive for products (
product-category/uncategorized/) - Open Google Tag Assistant so you can debug the events
- Click Add to Cart on the product
- Validate the the price value sent is in decimal format, i.e. 250.75
- Add the product to the cart again to increase the value
- Complete the purchase
- Ensure that the total purchase event amount is also in decimal format
- Note, if you choose a whole product price such as 500, the value is sent as 500 and not 500.00
Changelog entry
- Fix bug that could cause some WooCommerce events to have inaccurate prices.