Skip to content

Commit 0f5f9d9

Browse files
authored
patch: Adjusting google analytics events trigger
patch: Adjusting google analytics events trigger
2 parents 16ba68b + 3a5548d commit 0f5f9d9

5 files changed

Lines changed: 11 additions & 22 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"react-dnd": "^14.0.2",
1414
"react-dnd-html5-backend": "^14.0.0",
1515
"react-dom": "^17.0.2",
16-
"react-ga": "^3.3.0",
1716
"react-hook-form": "^7.12.2",
1817
"react-router-dom": "^5.2.0",
1918
"react-scripts": "4.0.3",

src/components/Modal/modalTag.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useContext, memo } from "react";
22
import { useForm } from "react-hook-form";
3-
import ReactGA from "react-ga";
43

54
//Scripts
65
import { dataContext } from "../../context/dataContext";
@@ -75,8 +74,8 @@ const ModalTag = ({ hideModal, showModal }) => {
7574
auxArr.push(auxObj);
7675
setTagList(auxArr);
7776

78-
ReactGA.event({
79-
category: "Create",
77+
window.gtag("event", "click-event", {
78+
event_category: "Create",
8079
action: "Creating a new tag",
8180
label: "Tag Creation",
8281
});

src/components/Modal/modalTodo.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useContext, memo } from "react";
22
import { useForm } from "react-hook-form";
3-
import ReactGA from "react-ga";
43

54
//Scripts
65
import { dataContext } from "../../context/dataContext";
@@ -87,8 +86,8 @@ const ModalTodo = ({ hideModal, showModal }) => {
8786
todoArr.push(todoObj);
8887
setTodoList(todoArr);
8988

90-
ReactGA.event({
91-
category: "Create",
89+
window.gtag("event", "click-event", {
90+
event_category: "Create",
9291
action: "Creating a new todo",
9392
label: "Todo Creation",
9493
});

src/components/SideBar/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useState, useContext } from "react";
2-
import ReactGA from "react-ga";
32
//Context
43
import { dataContext } from "../../context/dataContext.js";
54

@@ -27,8 +26,8 @@ const SideBar = () => {
2726
const [searchValue, setSearchValue] = useState("");
2827

2928
function handleClickAdd() {
30-
ReactGA.event({
31-
category: "Open",
29+
window.gtag("event", "click-event", {
30+
event_category: "Open",
3231
action: "Openned tag creation modal",
3332
label: "Tag Modal",
3433
});

src/pages/Main/app.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useContext, useState, useEffect } from "react";
22
import { Col, Drawer } from "antd";
3-
import ReactGA from "react-ga";
43

54
//Minor Components
65
import {
@@ -23,7 +22,6 @@ import ModalTodo from "../../components/Modal/modalTodo";
2322

2423
import { ToastContainer } from "react-toastify";
2524

26-
ReactGA.initialize('G-JF1788P5N0');
2725

2826
const App = () => {
2927
const [showModal, setShowModal] = useState(false);
@@ -41,18 +39,13 @@ const App = () => {
4139
}
4240
}, [])
4341

44-
useEffect(() => {
45-
46-
//to report page view
47-
ReactGA.pageview(window.location.pathname + window.location.search);
48-
}, [])
4942

5043
function handleClickAdd() {
51-
ReactGA.event({
52-
category: 'Open',
53-
action: 'Openned todo creation modal',
54-
label: 'Todo Modal'
55-
});
44+
window.gtag("event", "click-event", {
45+
event_category: "Open",
46+
action: "Openned todo creation modal",
47+
label: "Todo Modal"
48+
})
5649
setShowModal(true);
5750
}
5851

0 commit comments

Comments
 (0)