mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
fix: include items array in purchase dataLayer (#8339)
Include GA4-style `items` payload for subscription purchase events so GTM receives the full item array. So, to align with GA4's ecommerce standards, we changed it to an items array: https://developers.google.com/analytics/devguides/collection/ga4/item-scoped-ecommerce
This commit is contained in:
@@ -237,10 +237,14 @@ describe('useSubscription', () => {
|
||||
event: 'purchase',
|
||||
transaction_id: 'sub_123',
|
||||
currency: 'USD',
|
||||
item_id: 'monthly_creator',
|
||||
item_variant: 'monthly',
|
||||
item_category: 'subscription',
|
||||
quantity: 1
|
||||
items: [
|
||||
{
|
||||
item_id: 'monthly_creator',
|
||||
item_variant: 'monthly',
|
||||
item_category: 'subscription',
|
||||
quantity: 1
|
||||
}
|
||||
]
|
||||
})
|
||||
expect(localStorage.getItem('pending_subscription_purchase')).toBeNull()
|
||||
})
|
||||
|
||||
@@ -121,18 +121,21 @@ function useSubscriptionInternal() {
|
||||
: baseName
|
||||
const unitPrice = getTierPrice(tierKey, isYearly)
|
||||
const value = isYearly && tierKey !== 'founder' ? unitPrice * 12 : unitPrice
|
||||
|
||||
pushDataLayerEvent({
|
||||
event: 'purchase',
|
||||
transaction_id: status.subscription_id,
|
||||
value,
|
||||
currency: 'USD',
|
||||
item_id: `${billingCycle}_${tierKey}`,
|
||||
item_name: planName,
|
||||
item_category: 'subscription',
|
||||
item_variant: billingCycle,
|
||||
price: value,
|
||||
quantity: 1
|
||||
items: [
|
||||
{
|
||||
item_id: `${billingCycle}_${tierKey}`,
|
||||
item_name: planName,
|
||||
item_category: 'subscription',
|
||||
item_variant: billingCycle,
|
||||
price: value,
|
||||
quantity: 1
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
clearPendingSubscriptionPurchase()
|
||||
|
||||
Reference in New Issue
Block a user