Adds integrity of Google Optimize into your React app
npm install optimize-abtest
1. Install npm i optimize-abtest or yarn add optimize-abtest
2. Import import useAbTest from 'optimize-abtest'
3. Use const { variant } = useAbTest(' to compare with string variant1 or variant2
4. Or simply use const { isExperienceActive } = useAbTest(' if there's only 1 variant available
1. Create a new experiment
2. Add a variant to it
3. Edit Global JavaScript in the variant
4. Add the next two lines of code listed below:
```
window.dispatchEvent(new CustomEvent('
document.cookie = "
The package uses a session-long cookie named and one of its corresponding values either variant1 or variant2. const { variant } = useAbTest(' returns one of the strings either variant1 or variant2.isExperienceActive
Alternatively, you can import a boolean witch return either variant1` is active or not.