From d238a5926033e9a5415f2ebb3901b867e1404be0 Mon Sep 17 00:00:00 2001 From: John Kahookele Date: Sun, 3 Mar 2024 01:12:47 -1000 Subject: [PATCH 1/2] This will only work with your own created data analytic TRACKING ID. To test, type 'npm install react-ga4' into terminal and create a tracking ID in google analytics. From there, change tracking ID in index.js file. Please let me know if this is still needed for the website or not. --- package-lock.json | 6 ++++++ package.json | 1 + src/pages/index.js | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/package-lock.json b/package-lock.json index 452efbc..ddf2b9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "next": "^13.5.6", "react": "18.2.0", "react-dom": "18.2.0", + "react-ga4": "^2.1.0", "react-icons": "^4.8.0" }, "devDependencies": { @@ -3461,6 +3462,11 @@ "react": "^18.2.0" } }, + "node_modules/react-ga4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/react-ga4/-/react-ga4-2.1.0.tgz", + "integrity": "sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ==" + }, "node_modules/react-icons": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.8.0.tgz", diff --git a/package.json b/package.json index fd7d0a5..8b31a94 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "next": "^13.5.6", "react": "18.2.0", "react-dom": "18.2.0", + "react-ga4": "^2.1.0", "react-icons": "^4.8.0" }, "devDependencies": { diff --git a/src/pages/index.js b/src/pages/index.js index bd8763f..daf8cdb 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -3,8 +3,15 @@ import About from "@/components/About"; import Projects from "@/components/Projects"; import Timeline from "@/components/Timeline"; import Footer from "@/components/Footer"; +import React from 'react'; +import ReactGA from 'react-ga4'; // ga4 import export default function Home() { + + const TRACKING_ID = "G-4TRT9PDZQ9"; // Change tracking ID to use your own on Google Analytics. ID currently set is used for my development environment. + ReactGA.initialize(TRACKING_ID); + // ReactGA.pageview(document.location.pathname); // This line is currently causing 'ReferenceError: document is not defined in reactjs' + return ( <>
From a9e751e4a46266cb9b227c50b5df01897b547b5d Mon Sep 17 00:00:00 2001 From: John Kahookele Date: Sun, 3 Mar 2024 01:13:16 -1000 Subject: [PATCH 2/2] This will only work with your own created data analytic TRACKING ID. To test, type 'npm install react-ga4' into terminal and create a tracking ID in google analytics. From there, change tracking ID in index.js file. Please let me know if this is still needed for the website or not. --- src/pages/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.js b/src/pages/index.js index daf8cdb..d5455a2 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -22,7 +22,7 @@ export default function Home() {
); }