You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Existing add_to_cart and purchase events should be updated to include item_id for each item in the cart/purchase items list, as well as price.
EDD add_to_cart event can be also updated a bit to pull value from the cart total from the details object directly, instead of using individual item's value
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Easy Digital Downloads add_to_cart event items include item_id (in addition to the existing item_name/price).
Easy Digital Downloads purchase event includes an items list that mirrors the add_to_cart item fields (item_id, item_name, price).
purchase event fires regardless of gtagUserData flag; only user_data is conditional.
Implementation Brief
Update includes/Core/Conversion_Tracking/Conversion_Event_Providers/Easy_Digital_Downloads.php to keep using window._googlesitekit.edddata.purchase and extend its payload with purchase product data.
In maybe_add_purchase_data_from_session, build purchase product payload from $purchase_session['cart_details'] on the server side:
Map each cart item to item_id, item_name, price.
Include cart total value from purchase session details.
Keep payload normalized so frontend can consume directly without deep optional chaining.
Keep user_data generation in the same payload, but only attach user_data when gtagUserData is enabled and extracted data is non-empty.
Update provider event/hook gating so purchase is part of tracked EDD events regardless of gtagUserData feature flag.
Ensure that when adding a product to the cart, the add_to_cart event is triggered
It should have the currency, value (cart total), and an array of items, each with item_id, item_name and price
Ensure that when finalizing the checkout, the purchase event is tracked
When gtagUserData is disabled, it should have the currency, value (cart total), and an array of items, each with item_id, item_name and price
When gtagUserData is enabled, it should also have user_data
Ensure that the gtagUserData feature flag only affects whether user_data is included or not. The rest of the fields should be sent regardless of gtagUserData
Changelog entry
Improve enhanced conversion tracking for Easy Digital Downloads to include additional details.
Feature Description
Existing
add_to_cartandpurchaseevents should be updated to includeitem_idfor each item in the cart/purchaseitemslist, as well asprice.EDD
add_to_cartevent can be also updated a bit to pullvaluefrom the cart total from thedetailsobject directly, instead of using individual item's valueDo not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
add_to_cartevent items includeitem_id(in addition to the existingitem_name/price).purchaseevent includes an items list that mirrors theadd_to_cartitem fields (item_id,item_name,price).purchaseevent fires regardless ofgtagUserDataflag; onlyuser_datais conditional.Implementation Brief
includes/Core/Conversion_Tracking/Conversion_Event_Providers/Easy_Digital_Downloads.phpto keep usingwindow._googlesitekit.edddata.purchaseand extend its payload with purchase product data.maybe_add_purchase_data_from_session, build purchase product payload from$purchase_session['cart_details']on the server side:item_id,item_name,price.user_datageneration in the same payload, but only attachuser_datawhengtagUserDatais enabled and extracted data is non-empty.purchaseis part of tracked EDD events regardless ofgtagUserDatafeature flag.assets/js/event-providers/easy-digital-downloads.js:parseCartItemHTMLto returnitem_idfrom.edd-remove-from-cart[data-download-id].edd_cart_item_added, includeitem_idin items.add_to_cart(instead of deriving total from the single parsed item price).purchasewheneverglobal._googlesitekit?.edddata?.purchaseexists.user_dataattachment behindgtagUserDatacheck only.Test Coverage
assets/js/event-providers/easy-digital-downloads.test.jsto include tests foritem_idQA Brief
gtagUserDataadd_to_cartevent is triggeredcurrency,value(cart total), and an array ofitems, each withitem_id,item_nameandpricepurchaseevent is trackedgtagUserDatais disabled, it should have thecurrency,value(cart total), and an array ofitems, each withitem_id,item_nameandpricegtagUserDatais enabled, it should also haveuser_datagtagUserDatafeature flag only affects whetheruser_datais included or not. The rest of the fields should be sent regardless ofgtagUserDataChangelog entry