Skip to content

Commit 9d296a0

Browse files
committed
Google Analytics removed
1 parent efefa78 commit 9d296a0

3 files changed

Lines changed: 34 additions & 10 deletions

File tree

index.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
<title>Rack Planner</title>
9-
<!-- Google tag (gtag.js) -->
10-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KPDJTHLTEN"></script>
11-
<script>
12-
window.dataLayer = window.dataLayer || [];
13-
function gtag() { dataLayer.push(arguments); }
14-
gtag('js', new Date());
15-
16-
gtag('config', 'G-KPDJTHLTEN');
17-
</script>
189
</head>
1910

2011
<body>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rack-planner",
33
"private": true,
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/App.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ const WIDTH_19_INCH = Math.round(19 * PIXELS_PER_INCH);
2323
const WIDTH_10_INCH = Math.round(10 * PIXELS_PER_INCH);
2424
const RAIL_WIDTH = Math.round(0.625 * PIXELS_PER_INCH);
2525

26+
// Add window augmentation for Google Analytics
27+
declare global {
28+
interface Window {
29+
dataLayer: any[];
30+
gtag: (...args: any[]) => void;
31+
}
32+
}
33+
2634
export default function RackPlanner() {
2735
// --- State ---
2836
const [isDarkMode, setIsDarkMode] = useState(() => {
@@ -97,6 +105,31 @@ export default function RackPlanner() {
97105
localStorage.setItem('animationsEnabled', String(areAnimationsEnabled));
98106
}, [areAnimationsEnabled]);
99107

108+
// Handle Google Analytics
109+
useEffect(() => {
110+
const gaId = import.meta.env.VITE_GOOGLE_ANALYTICS_ID;
111+
112+
if (gaId && typeof window !== 'undefined') {
113+
// Load the script
114+
const script = document.createElement('script');
115+
script.async = true;
116+
script.src = `https://www.googletagmanager.com/gtag/js?id=${gaId}`;
117+
document.head.appendChild(script);
118+
119+
// Initialize dataLayer
120+
window.dataLayer = window.dataLayer || [];
121+
function gtag(...args: any[]) {
122+
window.dataLayer.push(args);
123+
}
124+
window.gtag = gtag;
125+
126+
gtag('js', new Date());
127+
gtag('config', gaId);
128+
129+
console.log('Google Analytics initialized with ID:', gaId);
130+
}
131+
}, []);
132+
100133
// Handle Responsive Scaling
101134
useEffect(() => {
102135
const handleResize = () => {

0 commit comments

Comments
 (0)