Skip to content

Commit

Permalink
setting up react-ga4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramin Farhadi authored and Ramin Farhadi committed Jul 15, 2024
1 parent d6fe748 commit 13deb2e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ VITE_REMOTE_HEADER_MENU_ID=23
VITE_REMOTE_FOOTER_MENU_ID=24
VITE_REMOTE_SOCIAL_LINKS_ID=26
VITE_LOCATION_API_URL=https://www.ucf.edu/wp-json/wp/v2/locations/
VITE_BASEURL= /map/
VITE_BASEURL=/map/
VITE_REACTGA_MEASUREMENT_ID=G-DFCVBKX579
7 changes: 0 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<!-- Google Tag Manager -->
<!-- <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-NDH5K9RN');</script> -->
<!-- End Google Tag Manager -->
<meta charset="UTF-8" />
<link rel="shortcut icon" href="/ucf.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.jpg">
Expand Down
7 changes: 7 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 @@ -34,6 +34,7 @@
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"react-ga4": "^2.1.0",
"togeojson": "^0.16.0",
"typescript": "^5.2.2",
"vite": "^5.2.0"
Expand Down
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './App.scss'
import ReactGA from "react-ga4"

// React Imports
import { useEffect, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -71,8 +72,15 @@ import campusData from './assets/campuses.json';
const TOKEN = import.meta.env.VITE_MAPBOX_TOKEN;
const FOOTER_MENU_ID = import.meta.env.VITE_REMOTE_FOOTER_MENU_ID;
const FOOTER_SOCIAL_ID = import.meta.env.VITE_REMOTE_SOCIAL_LINKS_ID;
const REACT_MEASUREMENT_ID = import.meta.env.VITE_REACTGA_MEASUREMENT_ID;

function App() {
ReactGA.initialize(REACT_MEASUREMENT_ID);

// Send pageview with a custom path
ReactGA.send({ hitType: "pageview", page: "/", title: "UCF Campus Map" });


const initialLng = -81.200142;
const intitalLat = 28.602368;
const initialZoom = 15;
Expand Down

0 comments on commit 13deb2e

Please sign in to comment.