Hey! I’m trying to set up A/B testing with Builder and NextJS.
In the examples I could find, only personalization
is used.
As I understood from the code, builder.tests.<contentId>
cookies should be used for A/B rendering. But I’m struggling with setting them up.
Currently, I pass req
and res
in builder.get
inside getServerSideProps
, variations
object exists in the model I fetch, but nothing happens with the cookies.
What are you trying to accomplish
I have several questions!
- Currently, I have only
builderSessionId
. What else cookies do I need for A/B tests working and how could I set them up? - What is the desired way of setting
builder.tests
cookies and using them? - Is there any example of working A/B tests with NextJS or any other framework?
Code I have
export const getServerSideProps: GetServerSideProps = async ({ req, res, params, locale }) => {
builder.init(process.env.NEXT_PUBLIC_BUILDER_PUBLIC_KEY ?? '', true, req, res);
const { attributes } = getPersonalizedURL(params?.page || []);
const result = await builder.get('header-navigation', {req, res, locale, userAttributes });
Thank you a lot!