-
Notifications
You must be signed in to change notification settings - Fork 2
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
1f8fbc9
commit c398408
Showing
3 changed files
with
22 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useEffect } from 'react'; | ||
import ReactGA from 'react-ga4'; | ||
|
||
const useGAInitialize = () => { | ||
useEffect(() => { | ||
ReactGA.initialize(process.env.GA_MANAGEMENT_ID || ''); | ||
}, []); | ||
}; | ||
|
||
export default useGAInitialize; |
10 changes: 10 additions & 0 deletions
10
frontend/src/lib/googleAnalytics/hooks/useGAPageTimeSpent.ts
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useEffect } from 'react'; | ||
import ReactGA from 'react-ga4'; | ||
|
||
const useGAPageTimeSpent = (page: string, timeSpent: number) => { | ||
useEffect(() => { | ||
ReactGA.send({ hitType: 'pageview', page, timeSpent }); | ||
}); | ||
}; | ||
|
||
export default useGAPageTimeSpent; |
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