2021-06-19 09:00:44 +00:00
|
|
|
export const GA_TRACKING_ID = process.env.GA_MEASUREMENT_ID
|
|
|
|
|
|
|
|
type GTagEvent = {
|
|
|
|
action: string
|
|
|
|
category: string
|
|
|
|
label: string
|
|
|
|
value: number
|
|
|
|
}
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export const pageview = (url: URL): void => {
|
|
|
|
;(window as any).gtag('config', GA_TRACKING_ID, {
|
2021-06-19 09:00:44 +00:00
|
|
|
page_path: url,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export const event = ({ action, category, label, value }: GTagEvent): void => {
|
|
|
|
;(window as any).gtag('event', action, {
|
2021-06-19 09:00:44 +00:00
|
|
|
event_category: category,
|
|
|
|
event_label: label,
|
|
|
|
value: value,
|
|
|
|
})
|
|
|
|
}
|