Skip to content

Commit 8c62b6f

Browse files
committed
Update absolute root
1 parent 19add74 commit 8c62b6f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

projects/client/src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Header } from 'common';
77

88
import Script from 'next/script';
99

10-
import * as gtag from '../libs/gtag';
10+
import * as gtag from 'client/libs/gtag';
1111

1212
import Providers from './providers';
1313

projects/client/src/libs/gtag.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
2+
3+
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
4+
export const event = (
5+
action: Gtag.EventNames,
6+
{ event_category, event_label, value }: Gtag.EventParams
7+
) => {
8+
window.gtag('event', action, {
9+
event_category,
10+
event_label,
11+
value,
12+
});
13+
};
14+
15+
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
16+
export const pageview = (url: URL) => {
17+
if (GA_TRACKING_ID)
18+
window.gtag('config', GA_TRACKING_ID, {
19+
page_path: url,
20+
});
21+
};

0 commit comments

Comments
 (0)