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

thankful-translator-73575

01/08/2024, 5:48 PM
Hello everyone, what could cause different variations to be saved for the same user_id?
f

fresh-football-47124

01/08/2024, 5:50 PM
Are you assigning based on user_id? sometimes we see that with the attribute conditionally. like id = user_id ?? another_id
t

thankful-translator-73575

01/08/2024, 5:53 PM
I do it by an id that I send in the "attributeId" field when sending the event to growthbook
f

fresh-football-47124

01/08/2024, 5:54 PM
so the assignment ID for the experiment is different than the user_id in the databsae? it would suggest that there is some non-persistance with one of those ids then.
t

thankful-translator-73575

01/08/2024, 6:00 PM
we are using google analytics 4 and we sent the same id as growthbook
f

fresh-football-47124

01/08/2024, 6:00 PM
can you share the code you have in the trackingCallback?
t

thankful-translator-73575

01/08/2024, 6:01 PM
sure:
Copy code
const attributeId = getCookie("apurataSessionId");
  const client = new window.growthbook.GrowthBook({
    apiHost: "<https://cdn.growthbook.io>",
    clientKey: "xxxxxx",
    subscribeToChanges: true,
    attributes: {
      id: attributeId,
    },
    trackingCallback: (experiment, result) => {
      dataLayer.push({
        event: "experiment_viewed",
        experimentId: experiment.key,
        variationId: result.key,
        attributeId: attributeId,
      });
    },
  });
It is a small population, but I think it can increase over time.
f

fresh-football-47124

01/08/2024, 6:34 PM
so the attributeId seems to be tied to the session
which will be less persistent than the user_id
t

thankful-translator-73575

01/08/2024, 8:09 PM
thanks, we continue checking the id
g

gray-coat-86984

01/16/2024, 9:43 PM
Hi @fresh-football-47124, I work on the same team as @thankful-translator-73575, we haven't found the problem yet. We use our Session.id as user_id because the login occurs way latter in our funnel. And this Session.id is stored in our database. But what do you mean exactly by "less persistent" and how could it generate the bug? Could you provide an example please?
f

fresh-football-47124

01/17/2024, 4:45 AM
well, you are bucketing users based on the session id, but doing the experiment reports based on another attribute.
if the user gets a new session id every session, then they may be assigned into different buckets- but when you look by user id, you'll get multiple exposures
g

gray-coat-86984

01/17/2024, 3:37 PM
actually we are getting the reports based on that exact same session_id, that's why it's so weird for us
f

fresh-football-47124

01/17/2024, 3:42 PM
is there any conditional logic there? like does it return one id while the cookie is being set?
g

gray-coat-86984

01/17/2024, 3:52 PM
not really, we only get the attributeId once, if it's None, it will remain None on trackingCallback. On the left, our instantiation of growthbook client, on the right, the usage where we have the problem of multiple exposures
hi @fresh-football-47124 did you have a chance to review our code?
t

thankful-translator-73575

01/19/2024, 9:07 PM
Hey again @fresh-football-47124 . Any update on the code review? Thanks!
f

fresh-football-47124

01/20/2024, 11:50 AM
you didn't share what is in the getCookie - like what does that return if the cookie isn't set?
do you see any 'experiment_viewed' events with a null or something strange for the attributeId column?
t

thankful-translator-73575

01/23/2024, 4:26 PM
hello @fresh-football-47124 thank you for your response, this is the code for the getCookie function.
If getCookie returns null, there would BE only one user_id = None with different variations, but in the example this value is not null and it does have two variations
f

fresh-football-47124

01/25/2024, 10:32 PM
You have user id, but what is the apurataSessionId? that's what your assigning on in the code
t

thankful-translator-73575

01/30/2024, 4:07 PM
the user_id is an alias when doing the query in GB ("t_session_id.value.string_value as user_id"), and the t_session_id is the getCookie("apurataSessionId") that is sent in the attributeId to analytics
here is the GrowthBook query
g

gray-coat-86984

02/06/2024, 3:53 PM
hi @fresh-football-47124 did you have a chance to check this? are we the only ones with this problem? how could we patch it at least? any ideas?
f

fresh-football-47124

02/06/2024, 3:55 PM
I don’t see something obviously wrong
g

gray-coat-86984

02/06/2024, 4:59 PM
we neither, we are stuck here 😞
f

fresh-football-47124

02/06/2024, 4:59 PM
You get no results?
g

gray-coat-86984

02/06/2024, 5:00 PM
we have results, but with this warning:
5 Views