-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathGA4Toggle.tsx
More file actions
39 lines (34 loc) · 1.05 KB
/
GA4Toggle.tsx
File metadata and controls
39 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as React from "react"
import Grid from "@mui/material/Grid/Grid"
import Switch from '@mui/material/Switch';
import Tooltip from '@mui/material/Tooltip';
import { GAVersion } from "@/constants"
interface GA4ToggleProps {
gaVersion: GAVersion
setGAVersion: (version: GAVersion) => void
}
const GA4Toggle: React.FC<GA4ToggleProps> = ({ setGAVersion, gaVersion }) => {
return (
<Tooltip title="Switch between UA and GA4 demos & tools">
<Grid component="label" container alignItems="center" spacing={1}>
<Grid item>UA</Grid>
<Grid item>
<Switch
checked={gaVersion === GAVersion.GoogleAnalytics4}
onChange={e => {
if (e.target.checked === true) {
setGAVersion(GAVersion.GoogleAnalytics4)
} else {
setGAVersion(GAVersion.UniversalAnalytics)
}
}}
name="use GA4"
color="primary"
/>
</Grid>
<Grid item>GA4</Grid>
</Grid>
</Tooltip>
)
}
export default GA4Toggle