mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Update useGoogleAnalytics.js
This commit is contained in:
@@ -6,15 +6,20 @@ const GA_MEASUREMENT_ID = "G-2M2VYEFL7B";
|
|||||||
const useGoogleAnalytics = () => {
|
const useGoogleAnalytics = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window.gtag === 'function') {
|
if (typeof window.gtag === 'function') {
|
||||||
const fullPath = location.pathname + location.search + location.hash;
|
const fullPath = location.pathname + location.search + location.hash;
|
||||||
window.gtag('config', GA_MEASUREMENT_ID, {
|
window.gtag('config', GA_MEASUREMENT_ID, {
|
||||||
'page_path': fullPath,
|
'page_path': fullPath,
|
||||||
});
|
});
|
||||||
window.gtag('event', 'page_view', {'page_path': fullPath});
|
window.gtag('event', 'page_view', {
|
||||||
}
|
'page_path': fullPath,
|
||||||
}, [location]);
|
'page_location': window.location.href
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useGoogleAnalytics;
|
export default useGoogleAnalytics;pat
|
||||||
|
|||||||
Reference in New Issue
Block a user