https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
d

dazzling-quill-18166

10/04/2022, 10:11 AM
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

future-teacher-7046

10/04/2022, 10:16 AM
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

dazzling-quill-18166

10/04/2022, 10:19 AM
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

future-teacher-7046

10/04/2022, 10:22 AM
When you do setAttributes, are you calling it "guestId" or just "id"?
d

dazzling-quill-18166

10/04/2022, 10:23 AM
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

future-teacher-7046

10/04/2022, 10:25 AM
Ok. And what is returned if you do
Copy code
growthbook.evalFeature("test-feature")
Specifically the "source" property of the returned object.
d

dazzling-quill-18166

10/04/2022, 10:30 AM
message has been deleted
f

future-teacher-7046

10/04/2022, 10:33 AM
That looks correct. You are assigning 100% of traffic to the first variation (true). And that is what the user is being assigned.
d

dazzling-quill-18166

10/04/2022, 10:39 AM
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

future-teacher-7046

10/04/2022, 10:47 AM
You were getting variation id 0 before, but are now getting variation id 1, so it seems to be working.
d

dazzling-quill-18166

10/04/2022, 11:28 AM
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
15 Views