Skip to content

Commit 78b0ba9

Browse files
committed
update to google analytics 4 property
1 parent c2bb09e commit 78b0ba9

File tree

10 files changed

+24
-21
lines changed

10 files changed

+24
-21
lines changed

.github/workflows/gh-deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Building 🧱
3232
run: yarn build
3333
env:
34-
NEXT_PUBLIC_TRACKING_ID: UA-182113713-1
34+
NEXT_PUBLIC_TRACKING_ID: G-8FBXBFXC10
3535
NEXT_PUBLIC_SERVICE_ID: service_qt4ryip
3636
NEXT_PUBLIC_TEMPLATE_ID: template_2ni69n8
3737
NEXT_PUBLIC_USER_ID: user_Do31sKneP4eYfn5n1nLTD

components/apps/gedit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import $ from 'jquery';
3-
import ReactGA from 'react-ga';
3+
import ReactGA from 'react-ga4';
44
import emailjs from '@emailjs/browser';
55

66
export class Gedit extends Component {

components/apps/terminal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react'
22
import $ from 'jquery';
3-
import ReactGA from 'react-ga';
3+
import ReactGA from 'react-ga4';
44

55
export class Terminal extends Component {
66
constructor() {

components/apps/vivek.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import ReactGA from 'react-ga';
2+
import ReactGA from 'react-ga4';
33

44
export class AboutVivek extends Component {
55

@@ -38,7 +38,8 @@ export class AboutVivek extends Component {
3838
localStorage.setItem("about-section", screen);
3939

4040
// google analytics
41-
ReactGA.pageview(`/${screen}`);
41+
ReactGA.send({ hitType: "pageview", page: `/${screen}`, title: "Custom Title" });
42+
4243

4344
this.setState({
4445
screen: this.screens[screen],

components/base/window.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import Draggable from 'react-draggable';
33
import Settings from '../apps/settings';
4-
import ReactGA from 'react-ga';
4+
import ReactGA from 'react-ga4';
55
import { displayTerminal } from '../apps/terminal'
66

77
export class Window extends Component {
@@ -28,14 +28,15 @@ export class Window extends Component {
2828
this.setDefaultWindowDimenstion();
2929

3030
// google analytics
31-
ReactGA.pageview(`/${this.id}`);
31+
ReactGA.send({ hitType: "pageview", page: `/${this.id}`, title: "Custom Title" });
3232

3333
// on window resize, resize boundary
3434
window.addEventListener('resize', this.resizeBoundries);
3535
}
3636

3737
componentWillUnmount() {
38-
ReactGA.pageview("/desktop");
38+
ReactGA.send({ hitType: "pageview", page: "/desktop", title: "Custom Title" });
39+
3940
window.removeEventListener('resize', this.resizeBoundries);
4041
}
4142

components/screen/desktop.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import AllApplications from '../screen/all-applications'
88
import DesktopMenu from '../context menus/desktop-menu';
99
import DefaultMenu from '../context menus/default';
1010
import $ from 'jquery';
11-
import ReactGA from 'react-ga';
11+
import ReactGA from 'react-ga4';
1212

1313
export class Desktop extends Component {
1414
constructor() {
@@ -36,7 +36,7 @@ export class Desktop extends Component {
3636

3737
componentDidMount() {
3838
// google analytics
39-
ReactGA.pageview("/desktop");
39+
ReactGA.send({ hitType: "pageview", page: "/desktop", title: "Custom Title" });
4040

4141
this.fetchAppsData();
4242
this.setContextListeners();

components/ubuntu.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import BootingScreen from './screen/booting_screen';
33
import Desktop from './screen/desktop';
44
import LockScreen from './screen/lock_screen';
55
import Navbar from './screen/navbar';
6-
import ReactGA from 'react-ga';
6+
import ReactGA from 'react-ga4';
77

88
export default class Ubuntu extends Component {
99
constructor() {
@@ -57,7 +57,7 @@ export default class Ubuntu extends Component {
5757

5858
lockScreen = () => {
5959
// google analytics
60-
ReactGA.pageview('/lock-screen');
60+
ReactGA.send({ hitType: "pageview", page: "/lock-screen", title: "Lock Screen" });
6161
ReactGA.event({
6262
category: `Screen Change`,
6363
action: `Set Screen to Locked`
@@ -71,7 +71,7 @@ export default class Ubuntu extends Component {
7171
};
7272

7373
unLockScreen = () => {
74-
ReactGA.pageview('/desktop');
74+
ReactGA.send({ hitType: "pageview", page: "/desktop", title: "Custom Title" });
7575

7676
window.removeEventListener('click', this.unLockScreen);
7777
window.removeEventListener('keypress', this.unLockScreen);
@@ -86,7 +86,8 @@ export default class Ubuntu extends Component {
8686
};
8787

8888
shutDown = () => {
89-
ReactGA.pageview('/switch-off');
89+
ReactGA.send({ hitType: "pageview", page: "/switch-off", title: "Custom Title" });
90+
9091
ReactGA.event({
9192
category: `Screen Change`,
9293
action: `Switched off the Ubuntu`
@@ -98,7 +99,7 @@ export default class Ubuntu extends Component {
9899
};
99100

100101
turnOn = () => {
101-
ReactGA.pageview('/desktop');
102+
ReactGA.send({ hitType: "pageview", page: "/desktop", title: "Custom Title" });
102103

103104
this.setState({ shutDownScreen: false, booting_screen: true });
104105
this.setTimeOutBootScreen();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"react": "^18.2.0",
2424
"react-dom": "^18.2.0",
2525
"react-draggable": "^4.4.5",
26-
"react-ga": "^3.3.1",
26+
"react-ga4": "^2.1.0",
2727
"react-onclickoutside": "^6.12.2",
2828
"tailwindcss": "^3.2.4"
2929
}

pages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Ubuntu from "../components/ubuntu";
2-
import ReactGA from 'react-ga';
2+
import ReactGA from 'react-ga4';
33
import Meta from "../components/SEO/Meta";
44

55
const TRACKING_ID = process.env.NEXT_PUBLIC_TRACKING_ID;

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@ react-draggable@^4.4.5:
559559
clsx "^1.1.1"
560560
prop-types "^15.8.1"
561561

562-
react-ga@^3.3.1:
563-
version "3.3.1"
564-
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
565-
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==
562+
react-ga4@^2.1.0:
563+
version "2.1.0"
564+
resolved "https://registry.yarnpkg.com/react-ga4/-/react-ga4-2.1.0.tgz#56601f59d95c08466ebd6edfbf8dede55c4678f9"
565+
integrity sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ==
566566

567567
react-is@^16.13.1:
568568
version "16.13.1"

0 commit comments

Comments
 (0)