Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New update function to ga4 ecommerce events #107

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions react/modules/gaEvents.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PixelMessage } from '../typings/events'
import updateEcommerce from './updateEcommerce'
import updateGA4Ecommerce from './gaUpdateEcommerce'
import {
getPrice,
getSeller,
Expand Down Expand Up @@ -45,7 +45,7 @@ export function viewItem(eventData: PixelMessage['data']) {
items: [item],
}

updateEcommerce(eventName, data)
updateGA4Ecommerce(eventName, data)
}

export function viewItemList(eventData: PixelMessage['data']) {
Expand All @@ -62,7 +62,7 @@ export function viewItemList(eventData: PixelMessage['data']) {
items,
}

updateEcommerce(eventName, data)
updateGA4Ecommerce(eventName, data)
}

export function selectItem(eventData: PixelMessage['data']) {
Expand Down Expand Up @@ -100,7 +100,7 @@ export function selectItem(eventData: PixelMessage['data']) {
items: [item],
}

updateEcommerce(eventName, data)
updateGA4Ecommerce(eventName, data)
}

export function selectPromotion(eventData: PixelMessage['data']) {
Expand All @@ -116,5 +116,5 @@ export function selectPromotion(eventData: PixelMessage['data']) {
promotion_name: promotion.name,
}

updateEcommerce(eventName, data)
updateGA4Ecommerce(eventName, data)
}
13 changes: 13 additions & 0 deletions react/modules/gaUpdateEcommerce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import push from './push'

export default function updateGA4Ecommerce(
event: string,
data: Record<string, unknown>
) {
push({ ecommerce: null })

push({
event,
ecommerce: data,
})
}