mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 14:59:39 +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',
|
event: 'purchase',
|
||||||
transaction_id: 'sub_123',
|
transaction_id: 'sub_123',
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
item_id: 'monthly_creator',
|
items: [
|
||||||
item_variant: 'monthly',
|
{
|
||||||
item_category: 'subscription',
|
item_id: 'monthly_creator',
|
||||||
quantity: 1
|
item_variant: 'monthly',
|
||||||
|
item_category: 'subscription',
|
||||||
|
quantity: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
expect(localStorage.getItem('pending_subscription_purchase')).toBeNull()
|
expect(localStorage.getItem('pending_subscription_purchase')).toBeNull()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -121,18 +121,21 @@ function useSubscriptionInternal() {
|
|||||||
: baseName
|
: baseName
|
||||||
const unitPrice = getTierPrice(tierKey, isYearly)
|
const unitPrice = getTierPrice(tierKey, isYearly)
|
||||||
const value = isYearly && tierKey !== 'founder' ? unitPrice * 12 : unitPrice
|
const value = isYearly && tierKey !== 'founder' ? unitPrice * 12 : unitPrice
|
||||||
|
|
||||||
pushDataLayerEvent({
|
pushDataLayerEvent({
|
||||||
event: 'purchase',
|
event: 'purchase',
|
||||||
transaction_id: status.subscription_id,
|
transaction_id: status.subscription_id,
|
||||||
value,
|
value,
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
item_id: `${billingCycle}_${tierKey}`,
|
items: [
|
||||||
item_name: planName,
|
{
|
||||||
item_category: 'subscription',
|
item_id: `${billingCycle}_${tierKey}`,
|
||||||
item_variant: billingCycle,
|
item_name: planName,
|
||||||
price: value,
|
item_category: 'subscription',
|
||||||
quantity: 1
|
item_variant: billingCycle,
|
||||||
|
price: value,
|
||||||
|
quantity: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
clearPendingSubscriptionPurchase()
|
clearPendingSubscriptionPurchase()
|
||||||
|
|||||||
Reference in New Issue
Block a user