Skip to content

Commit

Permalink
🧹 Chore: Add Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbakas authored Jun 28, 2024
2 parents c283d79 + 451927f commit fd8f0d4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
File renamed without changes
2 changes: 2 additions & 0 deletions src/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import "@semantyk/app/layout.css";
import { getMetadata } from "@semantyk/backend/logic/seo";
import SessionProvider from "@semantyk/frontend/logic/SessionProvider";
import Footer from "@semantyk/frontend/ui/components/molecules/Footer";
import Analytics from "@semantyk/frontend/logic/analytics/Analytics";


//* Main
Expand All @@ -29,6 +30,7 @@ export default function RootLayout({ children }) {
// Return
return (
<html lang="en">
<Analytics/>
<body id="App" className={"bg-dark text-light"}>
<SessionProvider>
{children}
Expand Down
39 changes: 39 additions & 0 deletions src/frontend/logic/analytics/Analytics.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
* # `GoogleAnalytics.jsx`
* client | Semantyk
*
* Created: Jun 28, 2024
* Modified: Jun 28, 2024
*
* Author(s): Semantyk Team
* Maintainer(s): Daniel Bakas <https://id.danielbakas.com>
*
* Copyright Β© Semantyk 2024. All rights reserved.
* –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*/

//* Imports
import React from "react";
import Script from "next/script";

//* Main
export default function Analytics() {
const gtag = "G-15WBDLX8S4";
return (<>
<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${gtag}`}
/>
<Script id="" strategy="lazyOnload">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gtag}', {
page_path: window.location.pathname,
});
`}
</Script>
</>);
};

0 comments on commit fd8f0d4

Please sign in to comment.