I’m trying to use the A/B split testing feature to serve two different versions of my site’s homepage (Gatsby), each one with a different header.
To do that I’ve created two branch deploys and enabled split testing, it seemed to work correctly, the only problem was that netlify always serves the same version of the site to a specific user, but I don’t need that behaviour for my use case.
I saw that this works through a “nf_ab” cookie returned from netlify on the first call to the CDN, so i thought i could override this behaviour by just deleting the cookie on each page load.
Just to take a test i tried to delete the cookie manually and refresh the page, it works almost all the time, but sometimes it returns a page with mixed elements from the two deploys.
I’ve made some debugging, and I think the problem is that at least sometimes the “nf_ab” cookie is not returned from the first network call, the one that returns the html document, but from one of the following, so this happens:
- User visits the page with no “nf_ab” cookie.
- The html document is requested, the request is handled by one of the two sites deploys, let’s call it “A”, but no “nf_ab” cookie is returned with it.
- With the last request a cookie is returned with the value corresponding to the “B” version, so the following requests are made correctly.
This leads to having problems on the site, like having the header background from the “A” version and the text from the “B” one, etc.
Thanks in advance for the help.