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

few-breakfast-69295

03/07/2024, 1:11 PM
Hi, Is there a way to assign a variation yourself to a new user, when initializing the GrowthBook instance on the client side? Some background: We use A/B testing on static pages with Next.js. When a static page is requested, the user is sent to the correct variation based on the attribute.id that is sent in the request headers with a cookie. When there is no cookie, then we let GrowthBook pick a variation in the middleware and sent the new attribute.id to the user with the cookies. Only we have a problem that when a user lands on our site for the first time, they first have to consent for cookies before we are allowed to use the cookies. We can still choose a random variant in the middleware. In the client-side we know the experiment variation that the user sees, but we don't have the cookie, so we need a way to assign the variation in the GrowthBook instance ourselfs instead of GrowthBook choosing for us.
f

fresh-football-47124

03/08/2024, 7:33 AM
hrmm, you dont need to use the growthBook SDK to do that - you could just fire the event yourself if you have already assigned them
f

few-breakfast-69295

03/08/2024, 7:42 AM
We could fire an "experiment viewed" tracking event manually, but if the visitor refreshes the page or visits it again later, we of course want to give the same variation. And that is only possible if this variation is linked to the attribute.id
7 Views