Hello everyone, what could cause different variati...
# ask-questions
t
Hello everyone, what could cause different variations to be saved for the same user_id?
f
Are you assigning based on user_id? sometimes we see that with the attribute conditionally. like id = user_id ?? another_id
t
I do it by an id that I send in the "attributeId" field when sending the event to growthbook
f
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
we are using google analytics 4 and we sent the same id as growthbook
f
can you share the code you have in the trackingCallback?
t
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
so the attributeId seems to be tied to the session
which will be less persistent than the user_id
t
thanks, we continue checking the id
g
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
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
actually we are getting the reports based on that exact same session_id, that's why it's so weird for us
f
is there any conditional logic there? like does it return one id while the cookie is being set?
g
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
Hey again @fresh-football-47124 . Any update on the code review? Thanks!
f
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
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
You have user id, but what is the apurataSessionId? that's what your assigning on in the code
t
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
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
I don’t see something obviously wrong
g
we neither, we are stuck here 😞
f
You get no results?
g
we have results, but with this warning: