This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NEXT_PUBLIC_GA_TRACKING_ID=G-ABC4850XYZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@/styles/index.css'; | |
import '@/styles/chrome-bug.css'; | |
import { AppProps, NextWebVitalsMetric } from 'next/app'; | |
import { useEffect, FC } from 'react'; | |
import { useRouter } from 'next/router'; | |
import * as gtag from '@/lib/analytics'; | |
const Noop: FC = ({ children }) => <>{children}</>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = useRouter(); | |
useEffect(() => { | |
const handleRouteChange = (url: URL) => { | |
gtag.pageview(url); | |
}; | |
router.events.on( | |
'routeChangeComplete', | |
handleRouteChange | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Document, { | |
Head, | |
Html, | |
Main, | |
NextScript, | |
DocumentContext, | |
DocumentProps, | |
DocumentInitialProps | |
} from 'next/document'; | |
import { GA_TRACKING_ID } from '@/lib/analytics'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Document, { | |
Head, | |
Html, | |
Main, | |
NextScript, | |
DocumentContext, | |
DocumentProps, | |
DocumentInitialProps | |
} from 'next/document'; | |
import { GA_TRACKING_ID } from '@/lib/analytics'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Head> | |
<meta charSet='utf-8' /> | |
<script | |
async | |
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} | |
/> | |
<script | |
dangerouslySetInnerHTML={{ | |
__html: `window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Document, { | |
Head, | |
Html, | |
Main, | |
NextScript, | |
DocumentContext, | |
DocumentProps, | |
DocumentInitialProps | |
} from 'next/document'; | |
import { GA_TRACKING_ID } from '@/lib/analytics'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const GA_TRACKING_ID = | |
process.env.NEXT_PUBLIC_GA_TRACKING_ID ?? ''; | |
export const pageview = (url: URL) => { | |
window.gtag('config', GA_TRACKING_ID, { | |
page_path: url | |
}); | |
}; | |
export const event = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface EventParams { | |
checkout_option?: string; | |
checkout_step?: number; | |
content_id?: string; | |
content_type?: string; | |
coupon?: string; | |
currency?: string; | |
description?: string; | |
fatal?: boolean; | |
items?: Item[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type EventNames = | |
| 'add_payment_info' | |
| 'add_to_cart' | |
| 'add_to_wishlist' | |
| 'begin_checkout' | |
| 'checkout_progress' | |
| 'exception' | |
| 'generate_lead' | |
| 'login' | |
| 'page_view' |
NewerOlder