-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#109][FEATURE] 구글 애널리틱스(GA) 도입
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID; | ||
|
||
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages | ||
export const pageview = (url: URL) => { | ||
if (typeof window.gtag === 'undefined') return; | ||
|
||
window.gtag('config', GA_TRACKING_ID as string, { | ||
page_path: url, | ||
}); | ||
}; | ||
|
||
interface GTagEventProps { | ||
action: string; | ||
category: string; | ||
label: string; | ||
value: number; | ||
} | ||
|
||
// https://developers.google.com/analytics/devguides/collection/gtagjs/events | ||
export const event = ({ action, category, label, value }: GTagEventProps) => { | ||
window.gtag('event', action, { | ||
event_category: category, | ||
event_label: label, | ||
value, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters