Skip to content

Commit

Permalink
Merge branch 'react-ga4' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramin Farhadi authored and Ramin Farhadi committed Jul 24, 2024
2 parents a9b5ca3 + 38ed2fb commit bb924df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './App.scss'
import ReactGA from "react-ga4"

// React Imports
import { useEffect, useMemo, useRef, useState } from 'react'

Expand Down Expand Up @@ -207,11 +206,16 @@ function App() {
if (response.length > 0) {
const location = response.pop();

ReactGA.set({
link_text: `${location!.title.rendered}`,
link_url: `${location!.link}`
})
ReactGA.event({
category: "link",
action: "click_internal_link",
label: `${location!.title.rendered}`,
});
})

html = `<a class="location-link" href="${location!.link}" onClick="{() => trackLinkClick(${location!.title.rendered}) }" target="_blank">${feature?.properties?.Name}</a>`;
} else {
html = `<span class="location-link">${feature?.properties?.Name}</span>`
Expand Down Expand Up @@ -264,6 +268,10 @@ function App() {
};

const campusHandler = (campus: Campus) => {
ReactGA.set({
link_text: `${campus.name}`,
link_url: ''
})
ReactGA.event({
category: "campus_menu",
action: "click_campus_menu",
Expand Down
1 change: 1 addition & 0 deletions src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function SearchResults(props: SearchResultsProps) {
}, [searchQuery, 500])

useEffect(() => {
ReactGA.set({});
ReactGA.event({
category: "map_search",
action: "search",
Expand Down

0 comments on commit bb924df

Please sign in to comment.