import { Experiment, Variant } from '@cyca/react-google-optimize';
const App = () => {
// note: please specify timeout else it defaults to INFINITY
// variant id default is 0
return (
<React.Suspense fallback="Loading...">
<Experiment id="YOUR_EXPERIMENT_ID" timeout={1000}>
<Variant>Default Variant</Variant>
<Variant id={1}>Experimental Variant</Variant>
</Experiment>
</React.Suspense>
);
};
// ----------------
// OR:
import { useGoogleOptimize } from '@cyca/react-google-optimize';
const MyExperiment = () => {
const variant = useGoogleOptimize('YOUR_EXPERIMENT_ID', 3000);
switch (variant) {
case 0:
return <div>Default Variant</div>;
case 1:
return <div>Alternative Variant</div>;
}
};
const App = () => (
<React.Suspense fallback="Loading...">
<MyExperiment />
</React.Suspense>
);
-
Notifications
You must be signed in to change notification settings - Fork 1
License
cvpcasada/react-google-optimize
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published