Skip to content

Use variations IDs in conversion events#3292

Merged
joemcgill merged 1 commit intodevelopfrom
fix/GOOWOO-503-purchase-events-variation-id
Mar 12, 2026
Merged

Use variations IDs in conversion events#3292
joemcgill merged 1 commit intodevelopfrom
fix/GOOWOO-503-purchase-events-variation-id

Conversation

@jjgrainger
Copy link
Collaborator

Changes proposed in this Pull Request:

Closes #3290

https://linear.app/a8c/issue/GOOWOO-503/purchase-event-sends-parent-product-id-instead-of-variation-id-for

Replace this with a good description of your changes & reasoning.

Detailed test instructions:

  1. Add a variable product to the cart.
  2. Go to the Cart page and view the page source and confirm that the gtag page view event uses the correct variation ID for the items ID.
  3. Proceed to checkout and complete the order.
  4. On the Order Received page, view the page source and confirm that the gtag purchase event uses the correct variation ID for the items ID.

Changelog entry

Fix - Conversion events use product variation ID in purchase events.

@github-actions github-actions bot added type: bug The issue is a confirmed bug. changelog: fix Took care of something that wasn't working. labels Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.1%. Comparing base (b8a7da7) to head (ad740c4).
⚠️ Report is 38 commits behind head on develop.

Files with missing lines Patch % Lines
src/Google/GlobalSiteTag.php 50.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             develop   #3292     +/-   ##
===========================================
+ Coverage       66.8%   67.1%   +0.2%     
- Complexity      5152    5154      +2     
===========================================
  Files            886     512    -374     
  Lines          26682   20567   -6115     
  Branches        1551       0   -1551     
===========================================
- Hits           17836   13791   -4045     
+ Misses          8646    6776   -1870     
+ Partials         200       0    -200     
Flag Coverage Δ
js-unit-tests ?
php-unit-tests 67.1% <50.0%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Google/GlobalSiteTag.php 35.9% <50.0%> (ø)

... and 374 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ankitguptaindia
Copy link
Collaborator

Test Report: Verified ✅

Environment

  • WordPress: 7.0-beta4-61919
  • PHP: 8.3.23
  • Server: nginx/1.26.1
  • Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.3.23)
  • Browser: Chrome 144.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Force GLA Billing Status to Approved 1.0
    • Google for WooCommerce 3.5.3
    • WooCommerce 10.6.0-rc.1
    • WooCommerce Beta Tester 3.0.0

Test Result

The issue has been fixed. Previously, when an order contained a variable product, the "event - page_view" and "event - purchase" were sending the parent product ID instead of the variation product ID.

Example from our test:

  • Parent Product ID: 206
  • Variation Product ID: 266

Before the fix, both events were reporting 206. After the fix, the correct variation product ID (266) is now being used.

Screenshot 2026-03-11 at 8 39 30 PM Screenshot 2026-03-11 at 8 39 52 PM

Befroe Fix:

event - page_view:


<script>
gtag("event", "page_view", {
send_to: "GLA",
ecomm_pagetype: "cart",
value: 300.000000,
items: [{
id: "gla_206",
price: 300.000000,
google_business_vertical: "retail",
name:"Sweater - Green",
quantity: 1,
}]});
</script>
 

event - purchase:


gtag("event", "purchase", {
			ecomm_pagetype: "purchase",
			send_to: "AW-17526712942/DeqACM6d9oUcEO7UsaVB",
			transaction_id: "277",
			currency: "USD",
			country: "US",
			value: 300.000000,
			new_customer: false,
			tax: 0.000000,
			shipping: 0.000000,
			delivery_postal_code: "282005",
			aw_feed_country: "US",
			aw_feed_language: "English",
			items: [{
				id: "gla_206",
				price: 300.000000,
				google_business_vertical: "retail",
				name: "Sweater - Green",
				quantity: 1,
				}]});

Recording.1735.mp4

After Fix:

event - page_view:


<script>
--
gtag("event", "page_view", {
send_to: "GLA",
ecomm_pagetype: "cart",
value: 600.000000,
items: [{
id: "gla_266",
price: 300.000000,
google_business_vertical: "retail",
name:"Sweater - Green",
quantity: 2,
}]});
</script>


event - purchase:

<script>
gtag("event", "purchase", {
			ecomm_pagetype: "purchase",
			send_to: "AW-17526712942/DeqACM6d9oUcEO7UsaVB",
			transaction_id: "278",
			currency: "USD",
			country: "US",
			value: 600.000000,
			new_customer: false,
			tax: 0.000000,
			shipping: 0.000000,
			delivery_postal_code: "282005",
			aw_feed_country: "US",
			aw_feed_language: "English",
			items: [{
				id: "gla_266",
				price: 300.000000,
				google_business_vertical: "retail",
				name: "Sweater - Green",
				quantity: 2,
				}]});
</script>

Recording.1734.mp4

@joemcgill joemcgill merged commit 2d60468 into develop Mar 12, 2026
14 checks passed
@joemcgill joemcgill deleted the fix/GOOWOO-503-purchase-events-variation-id branch March 12, 2026 20:42
@joemcgill joemcgill mentioned this pull request Mar 18, 2026
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Purchase event sends parent product ID instead of variation ID for variable products (GlobalSiteTag.php line 402)

4 participants