(gaId: string | null)
| 17 | : '') |
| 18 | |
| 19 | const googleAnalytics = (gaId: string | null) => { |
| 20 | if (!gaId) return '' |
| 21 | |
| 22 | return ` |
| 23 | <script async src="https://www.googletagmanager.com/gtag/js?id=${gaId}"></script> |
| 24 | <script> |
| 25 | window.dataLayer = window.dataLayer || []; |
| 26 | function gtag(){dataLayer.push(arguments);} |
| 27 | gtag('js', new Date()); |
| 28 | gtag('config', '${gaId}'); |
| 29 | </script> |
| 30 | ` |
| 31 | } |
| 32 | |
| 33 | type Variables = { |
| 34 | gaId: string | null, |