Closed mikkamp closed 7 months ago
Run e2e tests again, all tests passed except:
[chromium] › gtag-events/blocks-pages.test.js:160:2 › GTag events on block pages › Add to cart event is sent from a product collection block shop page
Which is related to the code change from https://github.com/woocommerce/woocommerce-google-analytics-integration/pull/378#issuecomment-1987786319. Not sure if I change the code locally wrong?
The code you changed is right, did you rebuild the assets after that change? I'm not quite sure why it would be failing otherwise. Maybe you can check the site at http://localhost:8889
to see how it handles the "Product Collection Shop" page. Make sure to add some test settings to enable tracking, during E2E that's enabled and cleared.
@tomalec Thanks for the review. Since this is approved and working, I'm going to merge it so we can focus on the other issues and get them tested. We can always refactor / change any other details later if needed.
Changes proposed in this Pull Request:
With the focus on shifting towards blocks yet still supporting classic pages, we have to cover the following types of pages to track their events:
To test this manually is a large burden. This PR copies over the E2E we have for tracking in GLA and modifies them to work with the GA events we send. This makes it easier to test the events across several different page/block types.
The tests in this PR did highlight some inconsitencies, and events that aren't being tracked, so the following changes are needed to make these tests pass:
Detailed test instructions:
nvm use && npm ci
npm start
ornpm run build
npm run wp-env:up
npx playwright install chromium
npm run test:e2e
Note: workflow is included (direct copy from GLA). We can only trigger it once this PR is merged (unless you want to clone the repo to test it).
Additional details:
These test aim to cover the most common scenarios, but while testing I still came across the following inconsistencies/parts we aren't covering (these can be addressed in follow up PR's):
[woocommerce_cart]
isn't always tracked because of immediate page redirect (not in E2E)[woocommerce_cart]
or with blocks (PR #375 removes it)begin_checkout
logs total item price (including discounts and price * quantity),purchase
logs product object price (not final price we paid in the order). Should these be consistent?woocommerce_add_to_cart
, should we get final price from cart_item_data? Otherwise we'll track product prices vs. discounted price.add_to_cart
, do we still capture all details?Changelog entry