mirror of
https://github.com/nickzuber/meteorite.git
synced 2024-08-16 06:50:29 +03:00
Upgrade to gtag
This commit is contained in:
parent
561d0dcb4a
commit
08acf46f97
@ -1,6 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-154218045-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-154218045-1');
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/iconCircle.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/new-app-icon.png">
|
||||
|
18
src/App.js
18
src/App.js
@ -4,7 +4,6 @@ import {
|
||||
Location,
|
||||
LocationProvider
|
||||
} from "@reach/router";
|
||||
import ReactGA from 'react-ga';
|
||||
import { routes } from './constants';
|
||||
import { AuthProvider } from './providers/Auth';
|
||||
import {
|
||||
@ -16,13 +15,24 @@ import {
|
||||
NotificationsRedesign,
|
||||
} from './pages';
|
||||
|
||||
// Initialize Google Analytics.
|
||||
ReactGA.initialize('UA-154218045-1');
|
||||
// @TODO: abstract further once confirmed this works.
|
||||
function gtag () {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
return () => {
|
||||
window.dataLayer.push(arguments);
|
||||
};
|
||||
}
|
||||
function gaTrack (options) {
|
||||
gtag('config', 'UA-154218045-1', options);
|
||||
}
|
||||
|
||||
// Effectively track each new page.
|
||||
function PageTracker ({location}) {
|
||||
React.useEffect(() => {
|
||||
ReactGA.pageview(location.pathname);
|
||||
gaTrack({
|
||||
page_location: location,
|
||||
page_path: location.pathname
|
||||
});
|
||||
}, [location]);
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user