mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Merge branch 'master' into master
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2M2VYEFL7B"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-2M2VYEFL7B');
|
||||
</script>
|
||||
<!-- ^ Google tag (gtag.js) ^ -->
|
||||
<meta charset="utf-8" />
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
|
||||
@@ -23,12 +23,14 @@ import { importAll } from './components/ImageBanner';
|
||||
import preloadImages from './utils/preloadImages';
|
||||
import showNewVersionToast from './utils/showNewVersionToast';
|
||||
import useError from './hooks/useError';
|
||||
import useGoogleAnalytics from './hooks/useGoogleAnalytics';
|
||||
import useInfo from './hooks/useInfo';
|
||||
import useSuccess from './hooks/useSuccess';
|
||||
import packageJson from '../package.json';
|
||||
const commitRef = process?.env?.REACT_APP_COMMIT_REF || '';
|
||||
|
||||
export default function App() {
|
||||
|
||||
const {
|
||||
bodyStyle,
|
||||
setBodyStyle,
|
||||
@@ -44,6 +46,7 @@ export default function App() {
|
||||
|
||||
const location = useLocation();
|
||||
const isElectron = window.electron && window.electron.isElectron;
|
||||
useGoogleAnalytics();
|
||||
|
||||
useEffect(() => {
|
||||
if (location.state?.scrollToTop) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
const GA_MEASUREMENT_ID = "G-2M2VYEFL7B";
|
||||
|
||||
const useGoogleAnalytics = () => {
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window.gtag === 'function') {
|
||||
const fullPath = location.pathname + location.search + location.hash;
|
||||
window.gtag('config', GA_MEASUREMENT_ID, {
|
||||
'page_path': fullPath,
|
||||
});
|
||||
window.gtag('event', 'page_view', {
|
||||
'page_path': fullPath,
|
||||
'page_location': window.location.href.replace('/#', '')
|
||||
});
|
||||
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
};
|
||||
|
||||
export default useGoogleAnalytics;
|
||||
Reference in New Issue
Block a user