Skip to content

Commit

Permalink
Merge pull request #108 from lfortran/use_goatcounter
Browse files Browse the repository at this point in the history
Use goat counter in place of Google Analytics
  • Loading branch information
Shaikh-Ubaid authored Sep 17, 2023
2 parents facb896 + 32310f3 commit ca7ca8e
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions components/MyLayout.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
import Script from "next/script";
import { useEffect } from "react";

import MyHeader from "./MyHeader";
import MyFooter from "./MyFooter";
import { Layout } from "antd";
import { Content } from "antd/lib/layout/layout";

const GA_MEASUREMENT_ID = "G-YJKXPHBZYC";

function MyLayout({ children }) {
return (
<Layout style={{backgroundColor: "inherit"}}>
{ /* Google tag (gtag.js) */}
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '${GA_MEASUREMENT_ID}');
`}
</Script>
useEffect(() => {
let script = document.createElement("script");
script.src = "//gc.zgo.at/count.js";
script.async = true;
script.setAttribute("data-goatcounter", "https://lfortran.goatcounter.com/count")
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
});

return (
<Layout style={{backgroundColor: "inherit"}}>
<MyHeader></MyHeader>
<Content style={{ padding: "10px 20px" }}>
{children}
Expand Down

0 comments on commit ca7ca8e

Please sign in to comment.