Skip to content

Commit

Permalink
use react-ga4
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterprovoost committed Jul 9, 2023
1 parent e78b8d6 commit b0244b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"react-bootstrap": "^2.7.0",
"react-bootstrap-icons": "^1.10.2",
"react-dom": "^18.2.0",
"react-ga4": "^2.1.0",
"react-leaflet": "^4.2.0",
"react-leaflet-draw": "^0.20.4",
"web-vitals": "^2.1.4"
Expand Down
11 changes: 0 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,5 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WT1E61C5VW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-WT1E61C5VW');
</script>

</body>
</html>
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import FullscreenControl from "./FullscreenControl";
import CRC32 from "crc-32";
import { EditControl } from "react-leaflet-draw";
import { geojsonToWKT } from "@terraformer/wkt";
import ReactGA from "react-ga4";

const DEFAULT_EPSG = "4326";
const USE_WKT = false;
Expand Down Expand Up @@ -224,6 +225,11 @@ function App() {
}).catch(error => console.error(error));
window.history.replaceState(null, null, "?" + hash);
setShowUrl(true);
ReactGA.event({
category: "wkt",
action: "wkt_share",
label: hash,
});
}

function loadExample() {
Expand Down
15 changes: 9 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import ReactGA from "react-ga4";

const root = ReactDOM.createRoot(document.getElementById('root'));
ReactGA.initialize("G-WT1E61C5VW");

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
Expand Down

0 comments on commit b0244b5

Please sign in to comment.