mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
Add back Google Analytics
This commit is contained in:
15
frontend/src/tracking.js
Normal file
15
frontend/src/tracking.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
export const usePageTracking = () => {
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
window.gtag("event", "page_view", {
|
||||
page_path: location.pathname + location.search + location.hash,
|
||||
page_search: location.search,
|
||||
page_hash: location.hash,
|
||||
});
|
||||
}, [location]);
|
||||
};
|
||||
Reference in New Issue
Block a user