Skip to content

Commit

Permalink
update package
Browse files Browse the repository at this point in the history
  • Loading branch information
dkireev committed Mar 23, 2021
1 parent 63f76fa commit 553b88b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Use optimize-abtest in code
1. Install `npm i optimize-abtest` or `yarn add optimize-abtest`
2. Import `import useAbTest from 'optimize-abtest'`
3. Use `const { variant } = useAbTest('<yourAbTestName>');`
3. Use `const { variant } = useAbTest('<yourAbTestName>');` to compare with string `variant1` or `variant2`
4. Or simply use `const { isExperienceActive } = useAbTest('<yourAbTestName>');` if there's only 1 variant available

# Set up Google Optimize experiment
1. Create a new experiment
Expand All @@ -17,4 +18,5 @@ document.cookie = "<yourAbTestName>=variant1";
```

## A bit of explanation here
The package uses a session-long cookie named `<yourAbTestName>` and one of its corresponding values either `variant1` or `variant2`. ```const { variant } = useAbTest('<yourAbTestName>');``` returns one of the strings either `variant1` or `variant2`
The package uses a session-long cookie named `<yourAbTestName>` and one of its corresponding values either `variant1` or `variant2`. ```const { variant } = useAbTest('<yourAbTestName>');``` returns one of the strings either `variant1` or `variant2`.
Alternatively, you can import a boolean `isExperienceActive` witch return either `variant1` is active or not.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"typescript": "^4.2.3"
},
"files": [
"**/*"
"index.js"
]
}

0 comments on commit 553b88b

Please sign in to comment.