diff --git a/website/src/google-analytics.ts b/website/src/google-analytics.ts new file mode 100644 index 0000000000..565e0fff8f --- /dev/null +++ b/website/src/google-analytics.ts @@ -0,0 +1,66 @@ +import { useEffect } from 'react' +import type { NextRouter } from 'next/router' + +// https://developers.google.com/analytics/devguides/collection/gtagjs/pages +const pageview = (url: string, trackingId: string) => { + ;(window as any).gtag('config', trackingId, { + page_path: url, + }) +} + +/** + * @example + * function AppWrapper(appProps: AppProps) { + * const { Component, pageProps, router } = appProps; + * const analytics = useGoogleAnalytics({ router, trackingId:"UA-XXXXXX-X" }); + * + * return ( + * <> + *