feat(SW-395): Added tracking to header and footer
This commit is contained in:
29
components/Footer/Details/SocialLink/index.tsx
Normal file
29
components/Footer/Details/SocialLink/index.tsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name"
|
||||||
|
import { trackSocialMediaClick } from "@/utils/tracking"
|
||||||
|
|
||||||
|
import type { SocialIconsProps } from "@/types/components/footer/socialIcons"
|
||||||
|
import type { SocialLinkProps } from "@/types/components/footer/socialLink"
|
||||||
|
import type { IconName } from "@/types/components/icon"
|
||||||
|
|
||||||
|
function SocialIcon({ iconName }: SocialIconsProps) {
|
||||||
|
const SocialIcon = getIconByIconName(iconName as IconName)
|
||||||
|
return SocialIcon ? <SocialIcon color="white" /> : <span>{iconName}</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SocialLink({ link }: SocialLinkProps) {
|
||||||
|
const { href, title } = link
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
color="white"
|
||||||
|
href={href}
|
||||||
|
key={title}
|
||||||
|
target="_blank"
|
||||||
|
aria-label={title}
|
||||||
|
onClick={() => trackSocialMediaClick(title)}
|
||||||
|
>
|
||||||
|
<SocialIcon iconName={title} />
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { getFooter, getLanguageSwitcher } from "@/lib/trpc/memoizedRequests"
|
import { getFooter, getLanguageSwitcher } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name"
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
import LanguageSwitcher from "@/components/LanguageSwitcher"
|
import LanguageSwitcher from "@/components/LanguageSwitcher"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
@@ -9,16 +8,10 @@ import Footnote from "@/components/TempDesignSystem/Text/Footnote"
|
|||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
import { getLang } from "@/i18n/serverContext"
|
import { getLang } from "@/i18n/serverContext"
|
||||||
|
|
||||||
|
import SocialLink from "./SocialLink"
|
||||||
|
|
||||||
import styles from "./details.module.css"
|
import styles from "./details.module.css"
|
||||||
|
|
||||||
import type { SocialIconsProps } from "@/types/components/footer/socialIcons"
|
|
||||||
import type { IconName } from "@/types/components/icon"
|
|
||||||
|
|
||||||
function SocialIcon({ iconName }: SocialIconsProps) {
|
|
||||||
const SocialIcon = getIconByIconName(iconName as IconName)
|
|
||||||
return SocialIcon ? <SocialIcon color="white" /> : <span>{iconName}</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function FooterDetails() {
|
export default async function FooterDetails() {
|
||||||
const lang = getLang()
|
const lang = getLang()
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
@@ -40,18 +33,7 @@ export default async function FooterDetails() {
|
|||||||
</Link>
|
</Link>
|
||||||
<nav className={styles.socialNav}>
|
<nav className={styles.socialNav}>
|
||||||
{footer?.socialMedia.links.map(
|
{footer?.socialMedia.links.map(
|
||||||
(link) =>
|
({ href }) => href && <SocialLink link={href} key={href.title} />
|
||||||
link.href && (
|
|
||||||
<a
|
|
||||||
color="white"
|
|
||||||
href={link.href.href}
|
|
||||||
key={link.href.title}
|
|
||||||
target="_blank"
|
|
||||||
aria-label={link.href.title}
|
|
||||||
>
|
|
||||||
<SocialIcon iconName={link.href.title} />
|
|
||||||
</a>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
import { ArrowRightIcon } from "@/components/Icons"
|
import { ArrowRightIcon } from "@/components/Icons"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||||
|
import { trackFooterClick } from "@/utils/tracking"
|
||||||
|
|
||||||
import styles from "./mainnav.module.css"
|
import styles from "./mainnav.module.css"
|
||||||
|
|
||||||
@@ -19,9 +22,9 @@ export default function FooterMainNav({ mainLinks }: FooterMainNavProps) {
|
|||||||
href={link.url}
|
href={link.url}
|
||||||
className={styles.mainNavigationLink}
|
className={styles.mainNavigationLink}
|
||||||
target={link.openInNewTab ? "_blank" : undefined}
|
target={link.openInNewTab ? "_blank" : undefined}
|
||||||
|
onClick={() => trackFooterClick("main", link.title)}
|
||||||
>
|
>
|
||||||
{link.title}
|
{link.title}
|
||||||
|
|
||||||
<ArrowRightIcon color="peach80" />
|
<ArrowRightIcon color="peach80" />
|
||||||
</Link>
|
</Link>
|
||||||
</Subtitle>
|
</Subtitle>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
import { getLang } from "@/i18n/serverContext"
|
import useLang from "@/hooks/useLang"
|
||||||
|
import { trackFooterClick, trackSocialMediaClick } from "@/utils/tracking"
|
||||||
|
|
||||||
import styles from "./secondarynav.module.css"
|
import styles from "./secondarynav.module.css"
|
||||||
|
|
||||||
@@ -13,7 +16,7 @@ export default function FooterSecondaryNav({
|
|||||||
secondaryLinks,
|
secondaryLinks,
|
||||||
appDownloads,
|
appDownloads,
|
||||||
}: FooterSecondaryNavProps) {
|
}: FooterSecondaryNavProps) {
|
||||||
const lang = getLang()
|
const lang = useLang()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.secondaryNavigation}>
|
<div className={styles.secondaryNavigation}>
|
||||||
@@ -28,18 +31,19 @@ export default function FooterSecondaryNav({
|
|||||||
</Caption>
|
</Caption>
|
||||||
<ul className={styles.secondaryNavigationList}>
|
<ul className={styles.secondaryNavigationList}>
|
||||||
{appDownloads.links.map(
|
{appDownloads.links.map(
|
||||||
(link) =>
|
({ href, type }) =>
|
||||||
link.href && (
|
href && (
|
||||||
<li key={link.type} className={styles.appDownloadItem}>
|
<li key={type} className={styles.appDownloadItem}>
|
||||||
<a
|
<a
|
||||||
href={link.href.href}
|
href={href.href}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
aria-label={link.href.title}
|
aria-label={href.title}
|
||||||
|
onClick={() => trackSocialMediaClick(href.title)}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={
|
src={
|
||||||
AppDownLoadLinks[
|
AppDownLoadLinks[
|
||||||
`${link.type}_${lang}` as keyof typeof AppDownLoadLinks
|
`${type}_${lang}` as keyof typeof AppDownLoadLinks
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
alt=""
|
alt=""
|
||||||
@@ -53,22 +57,23 @@ export default function FooterSecondaryNav({
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
)}
|
)}
|
||||||
{secondaryLinks.map((link) => (
|
{secondaryLinks.map((group) => (
|
||||||
<nav className={styles.secondaryNavigationGroup} key={link.title}>
|
<nav className={styles.secondaryNavigationGroup} key={group.title}>
|
||||||
<Caption
|
<Caption
|
||||||
color="textMediumContrast"
|
color="textMediumContrast"
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
type="label"
|
type="label"
|
||||||
>
|
>
|
||||||
{link.title}
|
{group.title}
|
||||||
</Caption>
|
</Caption>
|
||||||
<ul className={styles.secondaryNavigationList}>
|
<ul className={styles.secondaryNavigationList}>
|
||||||
{link?.links?.map((link) => (
|
{group?.links?.map((link) => (
|
||||||
<li key={link.title} className={styles.secondaryNavigationItem}>
|
<li key={link.title} className={styles.secondaryNavigationItem}>
|
||||||
<Link
|
<Link
|
||||||
href={link.url}
|
href={link.url}
|
||||||
target={link.openInNewTab ? "_blank" : undefined}
|
target={link.openInNewTab ? "_blank" : undefined}
|
||||||
color="burgundy"
|
color="burgundy"
|
||||||
|
onClick={() => trackFooterClick(group.title, link.title)}
|
||||||
>
|
>
|
||||||
{link.title}
|
{link.title}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { type PropsWithChildren } from "react"
|
|
||||||
|
|
||||||
import { login } from "@/constants/routes/handleAuth"
|
import { login } from "@/constants/routes/handleAuth"
|
||||||
|
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
@@ -9,6 +7,8 @@ import useLang from "@/hooks/useLang"
|
|||||||
import { useLazyPathname } from "@/hooks/useLazyPathname"
|
import { useLazyPathname } from "@/hooks/useLazyPathname"
|
||||||
import { trackLoginClick } from "@/utils/tracking"
|
import { trackLoginClick } from "@/utils/tracking"
|
||||||
|
|
||||||
|
import type { PropsWithChildren } from "react"
|
||||||
|
|
||||||
import type { TrackingPosition } from "@/types/components/tracking"
|
import type { TrackingPosition } from "@/types/components/tracking"
|
||||||
import type { LinkProps } from "@/components/TempDesignSystem/Link/link"
|
import type { LinkProps } from "@/components/TempDesignSystem/Link/link"
|
||||||
|
|
||||||
|
|||||||
6
types/components/footer/socialLink.ts
Normal file
6
types/components/footer/socialLink.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface SocialLinkProps {
|
||||||
|
link: {
|
||||||
|
href: string
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ export function trackPageViewStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function trackLoginClick(position: TrackingPosition) {
|
export function trackLoginClick(position: TrackingPosition) {
|
||||||
const loginEvent = {
|
const event = {
|
||||||
event: "loginStart",
|
event: "loginStart",
|
||||||
login: {
|
login: {
|
||||||
position,
|
position,
|
||||||
@@ -27,7 +27,27 @@ export function trackLoginClick(position: TrackingPosition) {
|
|||||||
ctaName: "login",
|
ctaName: "login",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pushToDataLayer(loginEvent)
|
pushToDataLayer(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trackSocialMediaClick(socialMediaName: string) {
|
||||||
|
const event = {
|
||||||
|
event: "social media",
|
||||||
|
social: {
|
||||||
|
socialIconClicked: socialMediaName,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
pushToDataLayer(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trackFooterClick(group: string, name: string) {
|
||||||
|
const event = {
|
||||||
|
event: "footer link",
|
||||||
|
footer: {
|
||||||
|
footerLinkClicked: `${group}:${name}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
pushToDataLayer(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function trackUpdatePaymentMethod(hotelId: string, method: string) {
|
export function trackUpdatePaymentMethod(hotelId: string, method: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user