I need to set up two redirect tests, but since Gro...
# give-feedback
w
I need to set up two redirect tests, but since GrowthBook doesn’t allow regex or multiple redirects, I’d like to ask if you think you could add this feature by November or December. Otherwise, I’ll need to use another tool, which I’d really prefer not to. We also need to A/B test a full redesign (I know, haha), and we haven’t found a way to do that with GrowthBook. Are there any possible workarounds?
@flaky-noon-11399
f
Hi Luan, we support regex URLs. https://docs.growthbook.io/app/visual
w
@flaky-noon-11399 but not for redirect A/B tests right?
f
Correct, for context which SDK are you using?
w
React SDK
I need to use redirect A/B, we are going to test a whole new website
f
When you say multiple redirects, you mean like a waterfall of redirects right?
w
No, I need to set up a redirect so that the homepage redirects to specific URL, then the product page redirects to a another specific URL and so forth. It's hundreds of pages, so we need regex for this
f
Ahhh got it, thank you for the context
In parallel to here, you may also wish to log this product gap in GitHub here so other customers can upvote it and you'll also be alerted of any updates directly from the Engineering team.
w
thank you!
f
My pleasure and totally understandable not wanting to do each redirect individually. I upvote this!
❤️ 1
w
I just submitted it!
r
Perfect, thank you 🚀
f
Hi Luan, our CTO has confirmed that supporting wildcard redirects is on our radar for a future roadmap but at this time we cannot confirm when this will be. In the meantime, it's super easy to do this using a feature flag today. It just requires writing a little code. if (gb.isOn("new-domain")) { const newURL = window.location.href.replace(/www.original.com/, 'www.new.com'); // Delay to give analytics tracking call time to fire setTimeout(function() {window.location.replace(newURL)}, 200); }
w
Why do we need this line? // Delay to give analytics tracking call time to fire setTimeout(function() {window.location.replace(newURL)}, 200);
r
This line of code you provided is using the ​`setTimeout`​ function to delay the execution of a redirect operation. Here's a breakdown of what it does: 1. ​`setTimeout`​ is a function that sets a timer and executes a function or specified piece of code once the timer expires. 2.​`function() {window.location.replace(newURL)}`​ is the function to be executed after the timer expires. This function uses the ​`window.location.replace`​ method to replace the current location with a new URL. The ​`newURL`​ should be a string representing the URL to which you want to redirect. 3.​`200`​ is the delay in milliseconds. In this case, the redirect will happen after 200 milliseconds (or 0.2 seconds).
We also provide a ​`navigate`​ option for controlling redirects, and a ​`navigateDelay`​ option for controlling the delay before redirecting- https://docs.growthbook.io/app/url-redirects#front-end-javascript-and-react-sdks
w
@flaky-noon-11399 is it possible to use Cloudflare workers for this?
f
Yes the Edge SDK will be able to facilitate this best
When performance is critical, we recommend doing A/B testing using Edge Workers instead of on the client. We have an example using Cloudflare here, but also support Fastly and AWS: https://docs.growthbook.io/lib/edge/cloudflare
This will be the best solution performance wise
w
@flaky-noon-11399 we can use the regex workaround you've provided with this?
f
I will have to look into if this works with the workaround but delay wise, this will be the best solution. About to step into a meeting but will investigate if it works with the workaround and get back to you as soon as the meeting is wrapped up
🙌 1
w
thank you so much!
youre welcome 1
🙏 1
looking forward to your answer!
f
Hi Luan, thank you for your patience. It has been a busy bee day. Yes Cloudflare can support this. We have an example of using feature flags in a Cloudflare Worker. https://docs.growthbook.io/lib/edge/cloudflare#manual-sdk-integration-on-edge
The gb.On equivalent in Cloudflare is growthbook.isOn
w
amazing!
thank you so much Natasha!
f
Our pleasure to assist 🙏
w
How would Growthbook handle the tracking callback? Will it fire once the user lands on the redirect and not fire it on the page where the feature flag is?
r
Apologies for the delayed response here. The ​`trackingCallback`​ is fired when a user is assigned a feature flag value based on an experiment. This includes redirect experiments. However, the exact location where the ​`trackingCallback`​ is fired can depend on how you've set up your GrowthBook instance and the specific code of your application.
🙌 1