Skip to content

Commit

Permalink
ga updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rolorogan committed May 28, 2024
1 parent c4370af commit 5cf5bc7
Show file tree
Hide file tree
Showing 3 changed files with 463 additions and 291 deletions.
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { RouterProvider, Navigate, createHashRouter} from "react-router-dom";
import Courses from './pages/courses';
import Course from './pages/course';
import { openDB } from 'idb';
import ReactGA from 'react-ga4';
const TRACKING_ID = "G-PL6P8LRKHT";
ReactGA.initialize(TRACKING_ID);

console.log('v1.0.9');
console.log('v1.0.10');

openDB('coursesDB', 1, {
upgrade(db) {
Expand Down
19 changes: 13 additions & 6 deletions src/pages/course/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import AccordionComponent from '../../components/accordion'
import { openDB } from 'idb'
import apiCourseProviderStorage from '../../services/apiCourseProviderStorage'
import ReactGA from 'react-ga4';
const TRACKING_ID = "G-PL6P8LRKHT";

export const findCourse = (courseArray, startDate, durationValue, locationName, courseID) => {
return courseArray.find(course => {
Expand Down Expand Up @@ -86,6 +87,17 @@ const Page = () => {
}
}

useEffect(() => {
ReactGA.initialize(TRACKING_ID);
// Send pageview with a custom path
ReactGA.send({
hitType: "pageview",
page: `/#/course-finder/details?courseId=${courseId}`,
title: courseName$._value,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);


useEffect(() => {
const fetchData = async () => {
Expand Down Expand Up @@ -115,11 +127,8 @@ const Page = () => {
// setCoursesCount(0);
}
};

// Send pageview with a custom path
ReactGA.send({ hitType: "pageview", page: `/#/course-finder/details?courseId=${courseId}`, title:courseName$._value });
fetchData();
}, [courseId, setPageRequest]);
}, []);

useEffect(() => {
const handleResize = () => {
Expand Down Expand Up @@ -378,11 +387,9 @@ const Course = () => {
const [courseName, setCourseName] = useState(undefined);

useEffect(() => {

courseName$.subscribe(name => {
setCourseName(name);
})

}, []);

const breadCrumb = [
Expand Down
Loading

0 comments on commit 5cf5bc7

Please sign in to comment.