+ Tum.ai uses cookies to enhance your experience, including essential functions like logging in, saving preferences, and personalizing content. We also use Google Analytics to monitor site usage and improve our services. If you continue to use this site, you agree that we can place these types of cookies on your device. You can manage your cookie preferences at any time in your browser settings.
+
+
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/components/GoogleAnalytics.tsx b/components/GoogleAnalytics.tsx
new file mode 100644
index 0000000..961360f
--- /dev/null
+++ b/components/GoogleAnalytics.tsx
@@ -0,0 +1,47 @@
+"use client";
+import Script from "next/script";
+import { usePathname, useSearchParams } from "next/navigation";
+import { useEffect } from "react";
+import { pageview } from "./lib/gtagHelper";
+
+export default function GoogleAnalytics({
+ GA_MEASUREMENT_ID,
+}: {
+ GA_MEASUREMENT_ID: string;
+}) {
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
+
+ useEffect(() => {
+ const url = pathname + searchParams.toString();
+
+ pageview(GA_MEASUREMENT_ID, url);
+ }, [pathname, searchParams, GA_MEASUREMENT_ID]);
+ return (
+ <>
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/components/lib/cookieStorage.ts b/components/lib/cookieStorage.ts
new file mode 100644
index 0000000..a6f4e70
--- /dev/null
+++ b/components/lib/cookieStorage.ts
@@ -0,0 +1,15 @@
+/* eslint-disable @typescript-eslint/no-unsafe-return */
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import "client-only";
+
+export function getLocalStorage(key: string, defaultValue: any){
+ const stickyValue = localStorage.getItem(key);
+
+ return (stickyValue !== null && stickyValue !== 'undefined')
+ ? JSON.parse(stickyValue)
+ : defaultValue;
+}
+
+export function setLocalStorage(key: string, value: any){
+ localStorage.setItem(key, JSON.stringify(value));
+}
\ No newline at end of file
diff --git a/components/lib/gtagHelper.ts b/components/lib/gtagHelper.ts
new file mode 100644
index 0000000..2a61fbf
--- /dev/null
+++ b/components/lib/gtagHelper.ts
@@ -0,0 +1,7 @@
+// components/lib/gtagHelper.tsx
+
+export const pageview = (GA_MEASUREMENT_ID : string, url : string) => {
+ window.gtag("config", GA_MEASUREMENT_ID, {
+ page_path: url,
+ });
+};
\ No newline at end of file
diff --git a/package.json b/package.json
index fb61d6b..b96f029 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
"@vercel/kv": "^1.0.1",
"axios": "^1.6.2",
"class-variance-authority": "^0.6.0",
+ "client-only": "^0.0.1",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.1",
"framer-motion": "^10.12.16",
@@ -44,6 +45,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
+ "@types/gtag.js": "^0.0.20",
"@types/node": "20.3.1",
"@types/react": "18.2.12",
"autoprefixer": "^10.4.14",