You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gtag.ts 479B

12345678910111213141516171819202122
  1. export const GA_TRACKING_ID = process.env.GA_MEASUREMENT_ID
  2. type GTagEvent = {
  3. action: string
  4. category: string
  5. label: string
  6. value: number
  7. }
  8. export const pageview = (url: URL): void => {
  9. ;(window as any).gtag('config', GA_TRACKING_ID, {
  10. page_path: url,
  11. })
  12. }
  13. export const event = ({ action, category, label, value }: GTagEvent): void => {
  14. ;(window as any).gtag('event', action, {
  15. event_category: category,
  16. event_label: label,
  17. value: value,
  18. })
  19. }