hi guys, i have a question related growthbook can ...
# ask-questions
i
hi guys, i have a question related growthbook can i do like this, let's say i passing
id = 5
, and then growthbook query to postgres (data source) to decide
id = 5
will treat as experiment or control?
w
Yes. Just make an experiment where the assignment attribute is id.
i
hmm how i can pass it and query based on that attributes ya?, i already implement SDK and set the attribute, but on growthbook side i only see this, which one i need to choose ya?
w
Add A/B experiment.
i
and which part i can add my query to decide the id treat as control / experiment
w
assign value based on attribute... it looks like it is already set to id.
i
hmm but on that part, how i can put my raw query ya?, i can't find it
h
Variation assignment is done on-the-fly using deterministic hashing at the SDK level; yours is configured to hash using the
id
field. If you want to track actual assignment events, you'll need to use the SDK's
trackingCallback
to log the user's assignment (and their attributes) to a warehouse.
i
if i not use growthbook variation assignment, and use id_tail to assignment its possible?
h
I believe you'd need to rig up a forced variation based on a new "forcedBucket" attribute. Then you'd need to pass forcedBucket into your attributes in the SDK. Something like...
Copy code
const forcedBucket = await getBucketByUserId(id);

gb.setAttributes({
  forcedBucket,
  etc...
});
...or bake the value of forcedBucket into your template. Either way, it would be some sort of DB lookup under the hood. Also note that doing your own bucketing limits your ability to control the test rollout using GrowthBook.
w
It is also possible that perhaps you want to use GB bucketing but just have a different id that you want to identify your users by and hash your experiments by. In that case you can set a new identifier type on your Metrics and Data> Data Sources > your data source page. Then set a new experiment assignment query that says how to get the experiment assignments by that id: https://docs.growthbook.io/app/datasources#identifier-types
i
let me read it first, and i'll be back with a questions 😅
👍 1
hi @white-fireman-22476 i already set a new identifier type, but how to connect it with i set attributes?
and the other questions, do you guys provide the experiment directly or we need to create query to out data warehouse?
w
hi @white-fireman-22476 i already set a new identifier type, but how to connect it with i set attributes?
You need to create both the identifier type and the experiment assignment query: https://docs.growthbook.io/app/datasources#experiment-assignment-queries. Hopefully the default for the event-source type that you choose can just be modified to use your new identifier type.
do you guys provide the experiment directly or we need to create query to out data warehouse?
When creating metrics we provide sample queries given the event-source type you selected when making your data source. They are provided as-is and may need to be modified to match your particular schema or to make them more performant.