Added Google Analytics

This commit is contained in:
Tom Butcher 2025-03-27 22:56:48 +00:00
parent a55c0575fe
commit 02b04da10d
4 changed files with 12 additions and 1 deletions

7
package-lock.json generated
View File

@ -18,6 +18,7 @@
"framer-motion": "^12.4.7", "framer-motion": "^12.4.7",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-ga4": "^2.1.0",
"react-icons": "^5.5.0", "react-icons": "^5.5.0",
"react-particles": "^2.12.2", "react-particles": "^2.12.2",
"react-responsive": "^10.0.0", "react-responsive": "^10.0.0",
@ -18874,6 +18875,12 @@
"integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==",
"license": "MIT" "license": "MIT"
}, },
"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==",
"license": "MIT"
},
"node_modules/react-icons": { "node_modules/react-icons": {
"version": "5.5.0", "version": "5.5.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz",

View File

@ -15,6 +15,7 @@
"framer-motion": "^12.4.7", "framer-motion": "^12.4.7",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-ga4": "^2.1.0",
"react-icons": "^5.5.0", "react-icons": "^5.5.0",
"react-particles": "^2.12.2", "react-particles": "^2.12.2",
"react-responsive": "^10.0.0", "react-responsive": "^10.0.0",

View File

@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import ReactGA from "react-ga4";
import { Layout, Space } from "antd"; import { Layout, Space } from "antd";
import { useLocation, useNavigate } from "react-router-dom"; import { useLocation, useNavigate } from "react-router-dom";
import { AnimatePresence, motion } from "framer-motion"; import { AnimatePresence, motion } from "framer-motion";
@ -24,6 +25,8 @@ const App = () => {
const isMobile = useMediaQuery({ maxWidth: 600 }); const isMobile = useMediaQuery({ maxWidth: 600 });
ReactGA.initialize(GA_MEASUREMENT_ID);
// Get the query parameter from the URL // Get the query parameter from the URL
const getQueryParam = (param) => { const getQueryParam = (param) => {
const searchParams = new URLSearchParams(location.search); // Use location.search directly const searchParams = new URLSearchParams(location.search); // Use location.search directly

View File

@ -31,7 +31,7 @@
* Environment Variables * Environment Variables
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
*/ */
// "vars": { "MY_VARIABLE": "production_value" }, "vars": { "GA_MEASUREMENT_ID": "G-MN5S04W1HB" },
/** /**
* Note: Use secrets to store sensitive data. * Note: Use secrets to store sensitive data.
* https://developers.cloudflare.com/workers/configuration/secrets/ * https://developers.cloudflare.com/workers/configuration/secrets/