Hello, I've got a problem with growthbook experime...
# ask-questions
d
Hello, I've got a problem with growthbook experiments. Consider this example. 1. I'm setting a cookie for a user
guestId
and passing it to
setAttributes
2. in growthbook GUI I've got 1 feature created
test-feature
with override rule set to
experiment
and 1 experiment corresponding with the feature 3.
guestId
was generated for the user when I had traffic set to
100%
and traffic split set to
old-view: 1
and
new-view: 0
4. After some tests I wanted to manipulate
traffic split
parameters so that I put
100%
to
old-view: 0
and
new-view: 1
5. Unfortunately for the same
guestId
I'm still receiving
old-view
variation My question is whether this behaviour is expected according to this piece of documentation
Copy code
In the vast majority of cases, you want to split traffic based on either a logged-in user id or some sort of anonymous identifier like a device id or session cookie. As long as the user has the same value for this attribute, they will always get assigned the same variation.
Only if I delete
guestId
and generate new one it seems that I receive proper variation. Thanks for your answer.
f
The assigned value for the user should change id you change the traffic split like that. The quote from the docs is only true if the traffic split remains the same.
What code are you using to pass the guestId into the SDK?
d
Im passing guestId via
setAttributes
. id is being generated with the use of this formula
Copy code
[...Array(30)].map(() => Math.random().toString(36)[2]).join("")
then Im putting it into cookie
f
When you do setAttributes, are you calling it "guestId" or just "id"?
d
Copy code
growthbook.setAttributes({
      "id": Cookies.get('guestId'),
      "loggedIn": true,
      "deviceId": "abcdef123456",
      "employee": true,
      "company": "acme",
      "country": "US",
      "browser": navigator.userAgent,
      "url": router.pathname,
    })
im calling it like in the docs
id
f
Ok. And what is returned if you do
Copy code
growthbook.evalFeature("test-feature")
Specifically the "source" property of the returned object.
d
message has been deleted
f
That looks correct. You are assigning 100% of traffic to the first variation (true). And that is what the user is being assigned.
d
Okey thanks for letting me know that this is fine. Can u consider this example? I just flipped traffic for the same example as we're discussing.
and somehow im still getting `new-view``
message has been deleted
I did not change/remove existing
guestId
f
You were getting variation id 0 before, but are now getting variation id 1, so it seems to be working.
d
It looks like I've got something wrong
message has been deleted
no matter if I change
traffic split
Im getting
variationId = 0
when triggering
growthBook.evalFeature('test-feature')
I get what I want when I remove
guestId
from
cookies
so that my script can assign a new one