add google gats
This commit is contained in:
@@ -35,4 +35,6 @@ NEXT_PUBLIC_FREE_RECORD_QUOTA=3
|
|||||||
NEXT_PUBLIC_FREE_URL_QUOTA=100
|
NEXT_PUBLIC_FREE_URL_QUOTA=100
|
||||||
|
|
||||||
# Open Signup
|
# Open Signup
|
||||||
NEXT_PUBLIC_OPEN_SIGNUP=1
|
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 ModalProvider from "@/components/modals/providers";
|
||||||
import { TailwindIndicator } from "@/components/tailwind-indicator";
|
import { TailwindIndicator } from "@/components/tailwind-indicator";
|
||||||
|
|
||||||
|
import GoogleAnalytics from "./GoogleAnalytics";
|
||||||
|
|
||||||
interface RootLayoutProps {
|
interface RootLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
@@ -48,6 +50,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
<TailwindIndicator />
|
<TailwindIndicator />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</SessionProvider>
|
</SessionProvider>
|
||||||
|
<GoogleAnalytics />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</ViewTransitions>
|
</ViewTransitions>
|
||||||
|
|||||||
@@ -109,16 +109,6 @@ export function NavMobile() {
|
|||||||
Sign in
|
Sign in
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li className="py-3">
|
|
||||||
<Link
|
|
||||||
href="/register"
|
|
||||||
onClick={() => setOpen(false)}
|
|
||||||
className="flex w-full font-medium capitalize"
|
|
||||||
>
|
|
||||||
Sign up
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export default async function HeroLanding() {
|
|||||||
variant: "outline",
|
variant: "outline",
|
||||||
rounded: "xl",
|
rounded: "xl",
|
||||||
size: "lg",
|
size: "lg",
|
||||||
|
className: "bg-primary-foreground hover:opacity-70",
|
||||||
}),
|
}),
|
||||||
"px-4 text-[15px]",
|
"px-4 text-[15px]",
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -26,16 +26,16 @@ export const docsConfig: DocsConfig = {
|
|||||||
href: "/docs/short-urls",
|
href: "/docs/short-urls",
|
||||||
icon: "page",
|
icon: "page",
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: "Terms of Service",
|
// title: "Terms of Service",
|
||||||
href: "/terms",
|
// href: "/terms",
|
||||||
icon: "page",
|
// icon: "page",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
title: "Privacy Policy",
|
// title: "Privacy Policy",
|
||||||
href: "/privacy",
|
// href: "/privacy",
|
||||||
icon: "page",
|
// icon: "page",
|
||||||
},
|
// },
|
||||||
// {
|
// {
|
||||||
// title: "Newsletter",
|
// title: "Newsletter",
|
||||||
// href: "/docs/newsletter",
|
// href: "/docs/newsletter",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ See docs about [guide](/docs/quick-start) for quick start.
|
|||||||
- [Cloudflare](https://dash.cloudflare.com/) account
|
- [Cloudflare](https://dash.cloudflare.com/) account
|
||||||
- A **domain** name hosted on Cloudflare
|
- A **domain** name hosted on Cloudflare
|
||||||
|
|
||||||
See docs about [developer](/docs/installation).
|
See docs about [developer](/docs/developer/installation).
|
||||||
|
|
||||||
## Local development
|
## 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