Skip to content

Commit

Permalink
Migrate to Google Analytics 4
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubois committed Aug 25, 2023
1 parent 53f3178 commit ad7b5f8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"path": "./target/angular/",
"environment": "all"
},
"packageManager": "yarn"
"packageManager": "yarn",
"analytics": false
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@angular/compiler-cli": "14.2.12",
"@openapitools/openapi-generator-cli": "1.0.10-4.2.3",
"@types/echarts": "^4.9.16",
"@types/google.analytics": "0.0.40",
"@types/gtag.js": "0.0.13",
"@types/jest": "27.5.2",
"@types/node": "12.12.17",
"@typescript-eslint/eslint-plugin": "5.36.1",
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export class JhonlineAppModule {
constructor(public router: Router, public googleAnalyticsEventsService: GoogleAnalyticsEventsService) {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
ga('set', 'page', 'start' + event.urlAfterRedirects);
ga('send', 'pageview');
gtag('set', 'page', 'start' + event.urlAfterRedirects);
gtag('event', 'pageview');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class GoogleAnalyticsEventsService {
public emitEvent(eventCategory: string, eventAction: string, eventLabel: string | null = null, eventValue: number | null = null): any {
ga('send', 'event', {
eventCategory,
gtag('event', 'eventCategory', {
eventLabel,
eventAction,
eventValue
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ <h1>You must enable javascript to view this page.</h1>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-4L9RJVPGJT');
</script>
</body>
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2638,18 +2638,18 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/[email protected]":
version "0.0.40"
resolved "https://registry.yarnpkg.com/@types/google.analytics/-/google.analytics-0.0.40.tgz#35526e9d78333423c430ade1c821ce54d0f0f850"
integrity sha512-R3HpnLkqmKxhUAf8kIVvDVGJqPtaaZlW4yowNwjOZUTmYUQEgHh8Nh5wkSXKMroNAuQM8gbXJHmNbbgA8tdb7Q==

"@types/graceful-fs@^4.1.3":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
integrity sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==
dependencies:
"@types/node" "*"

"@types/[email protected]":
version "0.0.13"
resolved "https://registry.yarnpkg.com/@types/gtag.js/-/gtag.js-0.0.13.tgz#54d746635e09fa61242e05b574b1ac068e6a90dd"
integrity sha512-yOXFkfnt1DQr1v9B4ERulJOGnbdVqnPHV8NG4nkQhnu4qbrJecQ06DlaKmSjI3nzIwBj5U9/X61LY4sTc2KbaQ==

"@types/http-proxy@^1.17.8":
version "1.17.9"
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.9.tgz#7f0e7931343761efde1e2bf48c40f02f3f75705a"
Expand Down

0 comments on commit ad7b5f8

Please sign in to comment.