-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repo:components): add google analytics component
- Loading branch information
David Rondio
authored and
David Rondio
committed
Sep 27, 2024
1 parent
3684241
commit 9720ed8
Showing
4 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Script from 'next/script'; | ||
|
||
const GoogleAnalytics = () => { | ||
return ( | ||
<> | ||
<Script | ||
strategy="lazyOnload" | ||
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`} | ||
/> | ||
|
||
<Script id="google-analytics" strategy="lazyOnload"> | ||
{` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', { | ||
page_path: window.location.pathname, | ||
}); | ||
`} | ||
</Script> | ||
</> | ||
); | ||
}; | ||
|
||
export default GoogleAnalytics; |