Contentful : Use AB Tasty to Serve the Right Variation
Use AB Tasty to Serve the Right Variation
This method only needs to be implemented once. However, it requires a front-end developer to update the site’s code so that the AB Tasty Variation Container from Contentful can be connected with the Flagship SDK. It will combine the Contentful API with a Feature Experimentation SDK to decide which content variation should be displayed to a user.
In the example below, a pseudo-backend retrieves the AB Tasty Variation Container from Contentful and leverages Feature Experimentation to select the appropriate variation for the visitor.
When you fetch a variation container entry from the Contentful API, the response includes the main fields:
experimentIdmetavariations
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "test"
}
},
"id": "FAKE_ID",
"type": "Entry",
"createdAt": "2025-08-28T13:49:03.977Z",
"updatedAt": "2025-08-28T13:49:03.977Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 3,
"revision": 1,
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "abTastyContainer"
}
},
"locale": "en-US"
},
"fields": {
"environmentId": "ci84rm4uf6t1jrrefeig",
"environment": "prod",
"experimentID": "d1ilgv373e5iv8esho80",
"experimentName": "TEST ContentFull",
"variations": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "5pDbSiwvTqtBthib8G1opA"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "5zKtmbcqb9ndM2wgU1KEmk"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "6QJmXjfiu91B7UpbjlKl1Z"
}
}
],
"meta": {
"d1ilgv373e5iv8esho90": "5pDbSiwvTqtBthib8G1opA",
"d1ili4eg4ajm59kcr1kg": "5zKtmbcqb9ndM2wgU1KEmk",
"d1j7hjfdv6k265cudqg0": "6QJmXjfiu91B7UpbjlKl1Z"
},
"projectId": "ci84rmkuf6t1jrrefejg"
}
}Decide on a Variation with Feature Experimentation
Use the Flagship SDK to decide which variation to present.
1. Initialize the SDK
2. Create a Visitor
3. Retrieve the Variation ID
AB Tasty selects the correct variation for the given visitorId based on the flag decision.
You can then use the variationId to retrieve the matching content entry from the variation container’s meta field.
Retrieve the Variation Entry from Contentful
From Contentful>Settings Menu> API keys
Retrieve SpaceID & Content Delivery API token
Click on Add an API key
Copy the Space ID
Copy the Content Delivery - access token
Click save if you've made any changes (You will be able to look back at both the space ID & the access token by clicking on your API name)
Use this code example to retrieve a variation entry // (replace the variable accordingly)
Result
This approach ensures a seamless link between the Flagship SDK and Contentful by mapping variationIds to content entries.
For each visitor, the correct variation is automatically selected and delivered—scalable, reliable, and consistent.
Last updated
Was this helpful?

