Skip to content

Commit

Permalink
Merge pull request #240 from vtexdocs/feat/googleAnalytics
Browse files Browse the repository at this point in the history
feat(header scripts): add GA script
  • Loading branch information
brunoamui authored Feb 13, 2023
2 parents 2ec249e + 5ba815c commit 60ad1ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Footer from 'components/footer'
import SidebarContextProvider from 'utils/contexts/sidebar'
import Sidebar from 'components/sidebar'
import { DocumentationTitle, UpdatesTitle } from 'utils/typings/unionTypes'
import Script from 'next/script'

interface Props {
sidebarfallback: any //eslint-disable-line
Expand Down Expand Up @@ -41,6 +42,21 @@ export default function Layout({
return (
<ThemeProvider>
<Header />
<div className="container">
<Script
src="https://www.googletagmanager.com/gtag/js?id=UA-56275648-4"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-56275648-4');
`}
</Script>
</div>
<Flex sx={styles.container}>
<SidebarContextProvider fallback={sidebarfallback}>
{!hideSidebar && (
Expand Down

0 comments on commit 60ad1ed

Please sign in to comment.