What are you trying to accomplish
I am trying to using the Builder SDK to fetch data of a specific variationId. I am storing the variationID in local storage and then I want to make sure I fetch the corresponding data. I am trying to use this get call, but it is still randomly bucketing users into the experiment. How can I force the data to return a specific variant?
import { builder } from “@builder.io/react”;
To force the Builder SDK to return data for a specific variationId , you should pass it explicitly as a query parameter in the userAttributes option. The reason your current approach is still bucketing users randomly is that Builder automatically assigns users to experiments unless you explicitly define the variant.
Solution: Use userAttributes to force a specific variant
Modify your get request like this:
javascript
import { builder } from "@builder.io/react";const variantId = localStorage.getItem("variationId"); // Retrieve from local storageconst data = await builder .get("checkout-flow", { userAttributes: { variationId: variantId, // Force a specific variation }, }) .promise();console.log(data);
Explanation:
Instead of passing id Inside options, use userAttributes.variationId.
Builder uses userAttributes to personalize content and explicitly setting variationId ensures the correct variant is returned.