I am conducting an A/B test experiment and I need to identify which variation is currently being used. How can I do this from within my codebase?
Hi @yuval222,
Which variation is going to serve is decided on the client side but you can certainly configure your code to access it in the content object as shown below
import { BuilderComponent } from '@builder.io/react'
<BuilderComponent
model="page"
contentLoaded={(data, content) => {
amplitude.track('builderImpression', {
contentId: content.id,
contentName: content.name,
testVariationId: content.testVariationId,
// Make sure to edit the variant name in Builder with a descriptive name
testVariationName: content.testVariationName
})
}
/>
You can find more about this at Using Builder with Customer Data Platforms - Builder.io
Im printing the content
object and get this:
{
"id": "0889bbd7a4a740449b24830bd48f60e1",
"data": {
"inputs": [],
"themeId": false,
"previewLink": "http://localhost:3000",
"noIndex": true,
"title": "Marble Life | Wills",
"blocks": [
// ...
]
}
}
i dont see any information regarding the ab test variartion
any idea?
Just a question @neri , are you using SSG/ISR or SSR for this page? FWIW, I’ve found that using SSR for pages with advanced logic (like A/B Testing) is far more reliable as it’s not a static page that gets overridden by client logic after it’s been pre-generated.
@chtbks-jason We use SSG/ISR. We use builder.io for our landing pages which are static pages so there’s no reason to use SSR
Thanks for the Tip