Some hotelInfo tracking on select-hotel page

This commit is contained in:
Linus Flood
2024-10-18 10:25:45 +02:00
parent 42640abb2b
commit bbf52c8dce
4 changed files with 30 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { Lang } from "@/constants/languages"
import { selectHotelMap } from "@/constants/routes/hotelReservation" import { selectHotelMap } from "@/constants/routes/hotelReservation"
import { import {
@@ -9,11 +10,17 @@ import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter"
import { ChevronRightIcon } from "@/components/Icons" import { ChevronRightIcon } from "@/components/Icons"
import StaticMap from "@/components/Maps/StaticMap" import StaticMap from "@/components/Maps/StaticMap"
import Link from "@/components/TempDesignSystem/Link" import Link from "@/components/TempDesignSystem/Link"
import TrackingSDK from "@/components/TrackingSDK"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import { setLang } from "@/i18n/serverContext" import { setLang } from "@/i18n/serverContext"
import styles from "./page.module.css" import styles from "./page.module.css"
import {
TrackingChannelEnum,
TrackingSDKHotelInfo,
TrackingSDKPageData,
} from "@/types/components/tracking"
import { LangParams, PageArgs } from "@/types/params" import { LangParams, PageArgs } from "@/types/params"
export default async function SelectHotelPage({ export default async function SelectHotelPage({
@@ -33,6 +40,22 @@ export default async function SelectHotelPage({
const filterList = getFiltersFromHotels(hotels) const filterList = getFiltersFromHotels(hotels)
const pageTrackingData: TrackingSDKPageData = {
pageId: "select-hotel",
domainLanguage: params.lang as Lang,
channel: TrackingChannelEnum["hotelreservation"],
pageName: "hotelreservation|select-hotel",
siteSections: "hotelreservation|select-hotel",
createdDate: "",
publishedDate: "",
pageType: "selecthotelpage",
}
const hotelsTrackingData: TrackingSDKHotelInfo = {
availableResults: hotels.length,
searchTerm: tempSearchTerm,
}
return ( return (
<main className={styles.main}> <main className={styles.main}>
<section className={styles.section}> <section className={styles.section}>
@@ -58,6 +81,7 @@ export default async function SelectHotelPage({
<HotelFilter filters={filterList} /> <HotelFilter filters={filterList} />
</section> </section>
<HotelCardListing hotelData={hotels} /> <HotelCardListing hotelData={hotels} />
<TrackingSDK pageData={pageTrackingData} hotelInfo={hotelsTrackingData} />
</main> </main>
) )
} }

View File

@@ -52,6 +52,8 @@ export default function RouterTransition({
} }
const pageObject = createSDKPageObject(trackingData) const pageObject = createSDKPageObject(trackingData)
console.log("TRACKING: Tracking initial pageView", pageObject) console.log("TRACKING: Tracking initial pageView", pageObject)
console.log("TRACKING: Tracking initial userData", userData)
console.log("TRACKING: Tracking initial hotelInfo", hotelInfo)
window.adobeDataLayer.push({ window.adobeDataLayer.push({
event: "pageView", event: "pageView",
pageInfo: pageObject, pageInfo: pageObject,
@@ -100,6 +102,8 @@ export default function RouterTransition({
"TRACKING: Tracking RouterTransition pageViewEnd", "TRACKING: Tracking RouterTransition pageViewEnd",
pageObject pageObject
) )
console.log("TRACKING: Tracking RouterTransition userData", userData)
console.log("TRACKING: Tracking RouterTransition hotelInfo", hotelInfo)
window.adobeDataLayer.push({ window.adobeDataLayer.push({
event: "pageViewEnd", event: "pageViewEnd",
pageInfo: pageObject, pageInfo: pageObject,

View File

@@ -5,6 +5,7 @@ import type { Lang } from "@/constants/languages"
export enum TrackingChannelEnum { export enum TrackingChannelEnum {
"scandic-friends" = "scandic-friends", "scandic-friends" = "scandic-friends",
"static-content-page" = "static-content-page", "static-content-page" = "static-content-page",
"hotelreservation" = "hotelreservation",
} }
export type TrackingChannel = keyof typeof TrackingChannelEnum export type TrackingChannel = keyof typeof TrackingChannelEnum

View File

@@ -49,6 +49,6 @@ export function createSDKPageObject(
...trackingData, ...trackingData,
domain: window.location.host, domain: window.location.host,
pageName: pageName, pageName: pageName,
siteSections: pageName, // TODO: We need to support other siteSections values in some cases. siteSections: pageName, //TODO: Always seems to be the same as pageName?
} }
} }