Add back Google Analytics

This commit is contained in:
Luke Berndt
2023-02-14 20:44:30 -05:00
parent 3a434f4654
commit 0d49d551b9
6 changed files with 71 additions and 77 deletions

15
frontend/src/tracking.js Normal file
View 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]);
};