tldraw/utils/gtag.ts
2021-06-19 10:00:44 +01:00

24 lines
479 B
TypeScript

export const GA_TRACKING_ID = process.env.GA_MEASUREMENT_ID
type GTagEvent = {
action: string
category: string
label: string
value: number
}
export const pageview = (url: URL) => {
// @ts-ignore
window.gtag('config', GA_TRACKING_ID, {
page_path: url,
})
}
export const event = ({ action, category, label, value }: GTagEvent) => {
// @ts-ignore
window.gtag('event', action, {
event_category: category,
event_label: label,
value: value,
})
}