Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GA, anonymized, no cookies #91

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-google-recaptcha": "^2.1.0",
"react-router-dom": "^5.3.3",
"typescript": "^4.7.4",
Expand Down
13 changes: 13 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
<title>Find Open-source projects with a social impact</title>
<meta name="description"
content="Pick a cause to support, find Open Source projects to contribute to, and make an impact! Write meaningful code, from environment, to health.">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C9SQS63TJQ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-C9SQS63TJQ',
{ 'anonymize_ip': true,
'client_storage': 'none',
'ad_storage': 'denied',
'analytics_storage': 'denied' }
);
</script>
</head>

<body>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import Typography from '@mui/material/Typography';

import { Link as RouterLink } from 'react-router-dom';

import useMinimalGaTracker from '../components/useMinimalGaTracker';

export default function PageHeader() {
useMinimalGaTracker();
return (
<header>
<Grid container spacing={2}>
Expand Down
17 changes: 17 additions & 0 deletions src/components/useMinimalGaTracker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const useMinimalGaTracker = () => {
const location = useLocation();

useEffect(() => {
if (!window.gtag) {
return;
}
window.gtag('config', 'G-C9SQS63TJQ', {
page_path: location.pathname + location.search,
});
}, [location]);
};

export default useMinimalGaTracker;
4 changes: 4 additions & 0 deletions src/gtag.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface Window {
gtag(...args: any[]): void;
}

4 changes: 0 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import ReactGA from 'react-ga';

import App from './App';

ReactGA.initialize('UA-177770802-1');
ReactGA.pageview(window.location.pathname + window.location.search);

const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(
<React.StrictMode>
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8829,11 +8829,6 @@ react-error-overlay@^6.0.11:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==

react-ga@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==

react-google-recaptcha@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/react-google-recaptcha/-/react-google-recaptcha-2.1.0.tgz#9f6f4954ce49c1dedabc2c532347321d892d0a16"
Expand Down
Loading