Merged in fix/tracking-requests (pull request #1208)
Added siteversion to all events and fixed payment status * Added siteversion to all events and fixed payment status * Fixed bug Approved-by: Erik Tiekstra
This commit is contained in:
@@ -11,7 +11,7 @@ export function trackClick(
|
||||
name: string,
|
||||
additionalParams?: Record<string, string>
|
||||
) {
|
||||
pushToDataLayer({
|
||||
trackEvent({
|
||||
event: "linkClick",
|
||||
cta: {
|
||||
...additionalParams,
|
||||
@@ -21,7 +21,7 @@ export function trackClick(
|
||||
}
|
||||
|
||||
export function trackPageViewStart() {
|
||||
pushToDataLayer({
|
||||
trackEvent({
|
||||
event: "pageViewStart",
|
||||
})
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export function trackLoginClick(position: TrackingPosition) {
|
||||
ctaName: "login",
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
trackEvent(event)
|
||||
}
|
||||
|
||||
export function trackSocialMediaClick(socialMediaName: string) {
|
||||
@@ -45,7 +45,7 @@ export function trackSocialMediaClick(socialMediaName: string) {
|
||||
socialIconClicked: socialMediaName,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
trackEvent(event)
|
||||
}
|
||||
|
||||
export function trackFooterClick(group: string, name: string) {
|
||||
@@ -55,7 +55,7 @@ export function trackFooterClick(group: string, name: string) {
|
||||
footerLinkClicked: `${group}:${name}`,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
trackEvent(event)
|
||||
}
|
||||
|
||||
export function trackHotelMapClick() {
|
||||
@@ -65,7 +65,7 @@ export function trackHotelMapClick() {
|
||||
action: "map click - open/explore mearby",
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
trackEvent(event)
|
||||
}
|
||||
|
||||
export function trackAccordionClick(option: string) {
|
||||
@@ -76,11 +76,11 @@ export function trackAccordionClick(option: string) {
|
||||
option,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
trackEvent(event)
|
||||
}
|
||||
|
||||
export function trackHotelTabClick(name: string) {
|
||||
pushToDataLayer({
|
||||
trackEvent({
|
||||
event: "linkClick",
|
||||
link: {
|
||||
action: "hotel menu click",
|
||||
@@ -99,7 +99,7 @@ export function trackUpdatePaymentMethod(hotelId: string, method: string) {
|
||||
name: method,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(paymentSelectionEvent)
|
||||
trackEvent(paymentSelectionEvent)
|
||||
}
|
||||
|
||||
export function trackOpenSidePeekEvent(
|
||||
@@ -119,7 +119,7 @@ export function trackOpenSidePeekEvent(
|
||||
pathName,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(openSidePeekEvent)
|
||||
trackEvent(openSidePeekEvent)
|
||||
}
|
||||
|
||||
export function trackPaymentEvent(paymentEvent: PaymentEvent) {
|
||||
@@ -130,7 +130,7 @@ export function trackPaymentEvent(paymentEvent: PaymentEvent) {
|
||||
},
|
||||
paymentInfo: {
|
||||
isSavedCreditCard: paymentEvent.isSavedCreditCard,
|
||||
status: "attempt",
|
||||
status: paymentEvent.status,
|
||||
type: paymentEvent.method,
|
||||
smsEnable: paymentEvent.smsEnable,
|
||||
errorMessage: isPaymentFailEvent(paymentEvent)
|
||||
@@ -138,7 +138,7 @@ export function trackPaymentEvent(paymentEvent: PaymentEvent) {
|
||||
: undefined,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(paymentAttempt)
|
||||
trackEvent(paymentAttempt)
|
||||
}
|
||||
|
||||
export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
|
||||
@@ -154,10 +154,17 @@ export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
|
||||
currency: event.currency,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(lowestRoomPrice)
|
||||
trackEvent(lowestRoomPrice)
|
||||
}
|
||||
|
||||
export function pushToDataLayer(data: any) {
|
||||
function trackEvent(data: any) {
|
||||
if (typeof window !== "undefined" && window.adobeDataLayer) {
|
||||
data = { ...data, siteVersion: "new-web" }
|
||||
window.adobeDataLayer.push(data)
|
||||
}
|
||||
}
|
||||
|
||||
export function trackPageView(data: any) {
|
||||
if (typeof window !== "undefined" && window.adobeDataLayer) {
|
||||
window.adobeDataLayer.push(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user