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

123456789101112131415161718192021222324
  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) => {
  9. // @ts-ignore
  10. window.gtag('config', GA_TRACKING_ID, {
  11. page_path: url,
  12. })
  13. }
  14. export const event = ({ action, category, label, value }: GTagEvent) => {
  15. // @ts-ignore
  16. window.gtag('event', action, {
  17. event_category: category,
  18. event_label: label,
  19. value: value,
  20. })
  21. }