add google gats
This commit is contained in:
@@ -36,3 +36,5 @@ NEXT_PUBLIC_FREE_URL_QUOTA=100
|
||||
|
||||
# Open Signup
|
||||
NEXT_PUBLIC_OPEN_SIGNUP=1
|
||||
|
||||
NEXT_PUBLIC_GOOGLE_ID=
|
||||
37
app/GoogleAnalytics.tsx
Normal file
37
app/GoogleAnalytics.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
import * as gtag from "../gtag.js";
|
||||
|
||||
const GoogleAnalytics = () => {
|
||||
return (
|
||||
<>
|
||||
{gtag.GA_TRACKING_ID ? (
|
||||
<>
|
||||
<Script
|
||||
strategy="afterInteractive"
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
|
||||
/>
|
||||
<Script
|
||||
id="gtag-init"
|
||||
strategy="afterInteractive"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', '${gtag.GA_TRACKING_ID}', {
|
||||
page_path: window.location.pathname,
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default GoogleAnalytics;
|
||||
@@ -10,6 +10,8 @@ import { Toaster } from "@/components/ui/sonner";
|
||||
import ModalProvider from "@/components/modals/providers";
|
||||
import { TailwindIndicator } from "@/components/tailwind-indicator";
|
||||
|
||||
import GoogleAnalytics from "./GoogleAnalytics";
|
||||
|
||||
interface RootLayoutProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
@@ -48,6 +50,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
||||
<TailwindIndicator />
|
||||
</ThemeProvider>
|
||||
</SessionProvider>
|
||||
<GoogleAnalytics />
|
||||
</body>
|
||||
</html>
|
||||
</ViewTransitions>
|
||||
|
||||
@@ -109,16 +109,6 @@ export function NavMobile() {
|
||||
Sign in
|
||||
</Link>
|
||||
</li>
|
||||
|
||||
<li className="py-3">
|
||||
<Link
|
||||
href="/register"
|
||||
onClick={() => setOpen(false)}
|
||||
className="flex w-full font-medium capitalize"
|
||||
>
|
||||
Sign up
|
||||
</Link>
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
@@ -45,6 +45,7 @@ export default async function HeroLanding() {
|
||||
variant: "outline",
|
||||
rounded: "xl",
|
||||
size: "lg",
|
||||
className: "bg-primary-foreground hover:opacity-70",
|
||||
}),
|
||||
"px-4 text-[15px]",
|
||||
)}
|
||||
|
||||
@@ -26,16 +26,16 @@ export const docsConfig: DocsConfig = {
|
||||
href: "/docs/short-urls",
|
||||
icon: "page",
|
||||
},
|
||||
{
|
||||
title: "Terms of Service",
|
||||
href: "/terms",
|
||||
icon: "page",
|
||||
},
|
||||
{
|
||||
title: "Privacy Policy",
|
||||
href: "/privacy",
|
||||
icon: "page",
|
||||
},
|
||||
// {
|
||||
// title: "Terms of Service",
|
||||
// href: "/terms",
|
||||
// icon: "page",
|
||||
// },
|
||||
// {
|
||||
// title: "Privacy Policy",
|
||||
// href: "/privacy",
|
||||
// icon: "page",
|
||||
// },
|
||||
// {
|
||||
// title: "Newsletter",
|
||||
// href: "/docs/newsletter",
|
||||
|
||||
@@ -28,7 +28,7 @@ See docs about [guide](/docs/quick-start) for quick start.
|
||||
- [Cloudflare](https://dash.cloudflare.com/) account
|
||||
- A **domain** name hosted on Cloudflare
|
||||
|
||||
See docs about [developer](/docs/installation).
|
||||
See docs about [developer](/docs/developer/installation).
|
||||
|
||||
## Local development
|
||||
|
||||
|
||||
15
gtag.js
Normal file
15
gtag.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GOOGLE_ID || null;
|
||||
|
||||
export const pageview = (url) => {
|
||||
window.gtag("config", GA_TRACKING_ID, {
|
||||
page_path: url,
|
||||
});
|
||||
};
|
||||
|
||||
export const event = ({ action, category, label, value }) => {
|
||||
window.gtag("event", action, {
|
||||
event_category: category,
|
||||
event_label: label,
|
||||
value: value,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user