I am trying to ensure that only users from a particular company are included in an experiment AND th...
b
I am trying to ensure that only users from a particular company are included in an experiment AND that only users in that company will see the variant UX. • Feature: I added a Rollout Rule based on companyId. But users from another company still get the "experiment_viewed" event. • Experiment: I added Attribute Targeting with the same rule, only target users with a particular companyId. Now, users from another company do not get "experiment_viewed". I have read the docs but I'm not sure how Attribute Targeting differs between Feature and Experiment. What is the purpose of Attribute Targeting in Features if it doesn't prevent the feature from appearing for the user? Is the feature still present, but never true? If anyone can explain the differences for me that would be awesome. Thank you!
r
Hi Shelagh, Thank you for writing in. Attribute targeting in GrowthBook can be used in both features and experiments, but they serve slightly different purposes in each context. To summarize, while attribute targeting in both features and experiments involves setting user attributes and using them to determine who should see a feature or be included in an experiment, the key difference lies in how the targeting is applied. In features, it's used to enable or disable the feature for users who meet the attributes. In experiments, it's used to determine the pool of users who are eligible for the experiment, and then a subset of these users are actually enrolled in the experiment based on the traffic allocation. ​*1. Feature Attribute Targeting:*​ In the context of features, attribute targeting is used to determine whether a feature flag should be enabled or not for a specific user. For example, you might want to enable a feature only for users from a specific country or users who have a certain attribute. You can set these attributes in the GrowthBook SDK and then use them in your feature targeting rules. ​*2. In the context of experiments,*​ attribute targeting is used to determine which users should be included in an experiment. For example, you might want to run an experiment only on users from a specific country or users who have a certain attribute. Just like with features, you can set these attributes in the GrowthBook SDK and then use them in your experiment targeting rules. However, there's an important distinction between attribute targeting in features and experiments. In experiments, the attribute targeting determines the pool of users who are eligible for the experiment. Then, a percentage of these users (based on the traffic allocation you set) are actually enrolled in the experiment. For example, if you have an experiment rule set up that has attribute targeting and traffic set to 10%, it means that of all users who meet the attributes, 10% are selected and enrolled in the experiment.
To ensure that only users from a particular company are included in an experiment and that only users in that company will see the variant, you can use the ​`hashAttribute`​ setting in GrowthBook. This setting allows you to assign variations based on an attribute other than the user ​`id`​. Here's an example of how you might implement this: const gb = new GrowthBook({ attributes: { id: "123", company: "acme", }, features: { "my-feature": { rules: [ // All users with the same "company" value // will be assigned the same variation { variations: ["A", "B"], hashAttribute: "company", }, // If "company" is empty for the user (e.g. if they are logged out) // The experiment will be skipped and fall through to this next rule { force: "A", }, ], }, }, }); In this example, all users with the same "company" value will be assigned the same variation. If the "company" attribute is empty for a user (e.g., if they are logged out), the experiment will be skipped and the user will be assigned the "A" variation by default. Please note that you need to replace ​`"acme"`​ with the name of the company you want to include in the experiment, and ​`"my-feature"`​ with the name of your feature or experiment. The variations "A" and "B" should also be replaced with the actual variations you want to test. Further information on this can be found here - https://docs.growthbook.io/lib/js#hash-attribute Hope this helps :)
b
Thank you @flaky-noon-11399! May I check I have this right please? So, with feature attributes, the feature will exist for all users (I can see it exists in the DevTools) but it will always be false/disabled for users who are not in the targeted company? If I set both Feature and Experiment targeting: • all users will have the feature according to the DevTools, but it will be disabled/off for all users who are not in the target company (controlled by Feature) • only users in the target company will be included in the experiment, and will be randomly assigned control or variant version of the Feature (controlled by Experiment) Do I actually need to set the Feature targeting? Or will Experiment targeting ensure that users from other companies won't see the feature? That would be preferred, in case I use the same feature in another experiment. The hash attributes sound very interesting for the future, but are not what I'm looking for right now.
r
Hi Shelagh, Good morning and thank you for your response 🌼 ​*​_• all users will have the feature according to the DevTools, but it will be disabled/off for all users who are not in the target company (controlled by Feature) • only users in the target company will be included in the experiment, and will be randomly assigned control or variant version of the Feature (controlled by Experiment)_​*​ Yes, all the above is correct. When you use feature attributes for targeting, the feature will exist for all users, but it will only be enabled for users who meet the targeting conditions. ​*​_Do I actually need to set the Feature targeting? Or will Experiment targeting ensure that users from other companies won't see the feature?_​*​ Yes, you need to set the Feature targeting if you want to ensure that the feature is only enabled for users from specific companies. Feature targeting in GrowthBook is used to determine whether a feature flag should be enabled or not for a specific user. If you want to enable a feature only for users from a specific company, you can set these attributes in the GrowthBook SDK and then use them in your feature targeting rules. On the other hand, Experiment targeting is used to determine which users should be included in an experiment. If you want to run an experiment only on users from a specific company, you can set these attributes in the GrowthBook SDK and then use them in your experiment targeting rules. However, this does not affect whether the feature is enabled or not for these users. In summary, if you want to ensure that users from other companies won't see the feature, you need to set the Feature targeting. Experiment targeting alone won't ensure this. Hope this helps :)
🙌 1
b
Thank you!
f
It's my pleasure to assist 🙏
159 Views