Skip to content

Commit

Permalink
Merge pull request #18 from onflow/nialexsan/gtag
Browse files Browse the repository at this point in the history
Looks great!
  • Loading branch information
Aliserag authored Dec 8, 2023
2 parents eee7ace + ce254e6 commit 5d40575
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ import { primaryFont } from "src/theme/typography";
import ProgressBar from "src/components/progress-bar";
import { MotionLazy } from "src/components/animate/motion-lazy";
import { SettingsProvider, SettingsDrawer } from "src/components/settings";
import GTag from "src/components/GTag";
import { GTAG_ID } from "src/config-global";

export default function RootLayout({ children }) {
return (
<html lang="en" className={primaryFont.className}>
<head>
<GTag gtagId={GTAG_ID} />
</head>
<body>
<SettingsProvider
defaultSettings={{
Expand Down
22 changes: 22 additions & 0 deletions src/components/GTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import PropTypes from "prop-types";
import Script from 'next/script'

export default function GTag({ gtagId }) {
return (<>
<Script async src={`https://www.googletagmanager.com/gtag/js?id=${gtagId}`}></Script>
<Script id="google-analytics">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gtagId}');
`}
</Script>
</>
);
}

GTag.propTypes = {
gtagId: PropTypes.string,
};
1 change: 1 addition & 0 deletions src/config-global.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const HOST_API = process.env.NEXT_PUBLIC_HOST_API;
export const GTAG_ID = process.env.GTAG_ID || ""

1 comment on commit 5d40575

@vercel
Copy link

@vercel vercel bot commented on 5d40575 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.