Skip to content

Commit

Permalink
developed merged with react-ga4
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 0075b62 + 795d6b7 commit 1631cf3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
38 changes: 13 additions & 25 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,14 @@ function App() {

if (response.length > 0) {
const location = response.pop();

ReactGA.gtag("set", "user_properties", {
link_url: `${location!.link}`
});

ReactGA.gtag("set", "user_properties", {
link_text: `${location!.title.rendered}`
});

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

ReactGA.gtag('event', 'click_internal_link', {
'event_category': 'link',
'event_label': `${location!.title.rendered}`,
'link_text': `${location!.title.rendered}`,
'link_url': `${location!.link}`
});

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 @@ -273,16 +265,12 @@ function App() {
};

const campusHandler = (campus: Campus) => {

ReactGA.gtag("set", "user_properties", {
link_text: `${campus.name}`
});

ReactGA.event({
category: "campus_menu",
action: "click_campus_menu",
label: `${campus.name}`,
});

ReactGA.gtag('event', 'click_campus_menu', {
'event_category': 'campus_menu',
'event_label': `${campus.name}`,
'link_text': `${campus.name}`
});

mapRef.current!.flyTo({
center: [
Expand Down
13 changes: 5 additions & 8 deletions src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ export default function SearchResults(props: SearchResultsProps) {

useEffect(() => {

ReactGA.gtag("set", "user_properties", {
link_text: `${debouncedSearchQuery}`
});
ReactGA.gtag('event', 'search', {
'event_category': 'map_search',
'event_label': `${debouncedSearchQuery}`,
'link_text': `${debouncedSearchQuery}`,
});

ReactGA.event({
category: "map_search",
action: "search",
label: `${debouncedSearchQuery}`,
});
},[debouncedSearchQuery])

return (
Expand Down

0 comments on commit 1631cf3

Please sign in to comment.