Skip to content

Commit

Permalink
Update root.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig authored Dec 19, 2024
1 parent 046e5d7 commit ab0645c
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion app/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MetaFunction,
Outlet,
Scripts,
LiveReload,
ScrollRestoration,
useLoaderData,
useLocation
Expand All @@ -29,6 +30,24 @@ export const meta: MetaFunction = () => {
];
};

function GoogleAnalytics() {
return (
<>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BQBBSBFGZG"></script>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BQBBSBFGZG');
`,
}}
/>
</>
);
}

export function Layout({ children }: { children: React.ReactNode }) {
const location = useLocation();
const gaTrackingId = "G-BQBBSBFGZG";
Expand Down Expand Up @@ -103,5 +122,18 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
}

export default function App() {
return <Outlet />;
return (
<html lang="en">
<head>
<Meta />
<Links />
<GoogleAnalytics /> {/* Include Google Analytics here */}
</head>
<body>
<Outlet />
<Scripts />
<LiveReload />
</body>
</html>
);
}

0 comments on commit ab0645c

Please sign in to comment.