-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6b0194
commit 9b4383e
Showing
1 changed file
with
7 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
import './App.css'; | ||
import Home from "./components/home/Home"; | ||
import {useEffect} from "react"; | ||
import ReactGA from 'react-ga4'; | ||
import Home from './components/home/Home'; | ||
import useGoogleAnalytics from './hooks/useGoogleAnalytics'; | ||
|
||
function App() { | ||
const trackingId = process.env.REACT_APP_GOOGLE_ANALYTICS_TOKEN; | ||
|
||
useEffect(() => { | ||
if (trackingId) { | ||
// Initialize Google Analytics using the tracking ID from environment variables | ||
ReactGA.initialize(trackingId); | ||
|
||
// Track the initial page load | ||
ReactGA.send('pageview'); | ||
} else { | ||
console.warn('Google Analytics tracking ID is not set.'); | ||
} | ||
}, []);// The empty dependency array ensures this runs once on mount | ||
|
||
return ( | ||
<Home/> | ||
); | ||
const trackingId = process.env.REACT_APP_GOOGLE_ANALYTICS_TOKEN; | ||
useGoogleAnalytics(trackingId); | ||
return ( | ||
<Home/> | ||
); | ||
} | ||
|
||
export default App; |