Hello, I am wondering is there a way to check if f...
# announcements
Hello, I am wondering is there a way to check if feature is on for user without enrolling him into the experiment. I thought
does that but from what I can see it just calls evalFeature under the hood which per docs calls tracking. Our use case is that we have specific conditions on when user needs to be enrolled in the experiment so we can't enroll him just to check if feature is on. For example we have 3 CTAs which change based on the experiment. All of those need to check if feature is on but only one of them should actually trigger enrollment.
Hey, Ante - what sort of conditions will need to be checked. When building an experiment rule, you can add targeting conditions so you can limit who is included in an experiment. E.G. You can pass in attributes for country, and you can add targeting conditions to so only users in certain countries are included in the experiment. From there, you can have the 3 CTA variations in the experiment.
It's not a matter of variations. It's just a matter checking if feature is enabled without enabling it. Code example (it might be easier to grasp)
Copy code
const isFeatureEnabled = useIsFeatureEnabled('feature')

{isFeatureEnabled && <ButtonA />}
{isFeatureEnabled && <ButtonB />}
<ButtonC onClick={() => {
} />
In the above feature will be enabled as soon as
is called. We want it to get enabled only on
So, if I'm understanding correctly, you only want someone to enter the experiment when they click
<ButtonC />
. But, for the conditional rendering, you need to know if they're in the experiment to know whether to show the buttons. Is that correct?
To answer your original question - no, there isn't a way to see if the user is in an experiment without bucketing them into it that I'm aware of. You can add targeting conditions, so, for example, if you had a user attribute of
, the user would only be bucketed into the experiment (and thus, fire the tracking callback) if that was true. If it wasn't,
would just return false without firing the tracking callBack.
One thing that might be helpful, you the Javascript SDK does have a handy
method - so onClick, you can update the user's attributes. But, you'll want to make sure that the attributes can persist so the next time they land on this page or any others, they have the necessary attributes, otherwise, they might get different variations on subsequent visits.