How to create A/B Test for Dynamic URL? Step-by-step Tutorial
Quick answer
To A/B test dynamic URLs (filtered product pages, session-personalized pages), use a URL-redirect test that normalizes query parameters and assigns users to a variant URL at the server or CDN level rather than in the browser. This ensures each visitor consistently sees the same variant across requests and prevents search engines from indexing multiple URL versions.
Key takeaways
- Dynamic URLs with session-specific parameters require server-side or edge-based traffic splitting — browser-only redirects cause flickering and inconsistent variant assignment.
- Use wildcard (*) patterns in Mida to match entire URL families so one experiment covers thousands of product, category, or blog URLs at once.
- Normalize query parameters in your redirect rules so variant assignment is consistent across paginated, filtered, or sorted URL variants.
- Set canonical tags on all variant pages pointing to the original URL to prevent search engines from indexing duplicate content.
- Bots and crawlers are automatically excluded from the redirect — they always see the original control URL, which keeps your canonical index clean.
You might be wondering, "Why can't I just use regular URLs?"
Well, you could, but here's the catch: When you're dealing with e-commerce websites or sites that have fluid content, dynamic URLs come into play. These URLs are generated on the fly with each session or user. For instance, when users filter or sort results, or shop with personalized preferences.
The challenge lies in effectively running A/B tests on these dynamically generated webpages which differ from user to user.
Let's dive in on how to create an A/B Test for a dynamic URL.
What Is a Dynamic URL?
A dynamic URL is a web address generated automatically — usually by a database, CMS, or server — rather than pointing to a fixed, hand-crafted file. You can typically spot them by the presence of query strings, numeric IDs, or path segments that change with each product, category, or user session.
Examples of dynamic URLs include:
- E-commerce product pages: https://shop.example.com/product/running-shoes/id/4482
- Search results with filters: https://example.com/search?category=shoes&color=red&sort=price_asc
- Paginated listing pages: https://example.com/blog?page=3
- Session-personalized landing pages: https://example.com/lp/summer-sale?utm_id=abc123&user=xyz
The key thing these all have in common: there is no single canonical "control" URL you can hardcode into an experiment. Instead there is a URL pattern — and that pattern needs to be matched as a whole in your experiment setup.
Why Dynamic URLs Create A/B Testing Challenges
Standard A/B testing tools handle a fixed URL cleanly: show variation A to 50% of visitors, variation B to the other 50%, and track which converts better. But with dynamic URLs, the same product page might be visited at hundreds of different URL paths. If your experiment only targets one specific URL, you miss every other variant of that page.
Here are the three core challenges dynamic URLs introduce:
1. Scale: Too Many URLs to Target Individually
An e-commerce store with 10,000 SKUs could have 10,000 unique product URLs. Creating a separate experiment for each one is impractical — and it would burn through your monthly tested user quota instantly. You need a way to match a URL pattern, not a specific URL.
2. Consistency: Visitors Must See the Same Variant
If a visitor lands on /product/sneakers/id/1001 and sees the new layout, then navigates away and returns later, they should still see the new layout. Variant assignment must be sticky — tied to the visitor, not the specific URL string they happened to use on that session.
3. SEO: Avoiding Duplicate Content Penalties
When you redirect users to a variant URL (e.g., /product-v2/sneakers/id/1001), search engine crawlers may discover and index that variant URL separately from the original. Without a canonical tag pointing back to the original, you risk duplicate content issues — two pages with nearly identical content competing for the same rankings.
Free A/B Testing Tool
Run your next A/B test the right way
Visual editor, 15 KB script, GA4-native — and free forever up to 100,000 monthly visitors. No developer required.
Common Use Cases for Dynamic URL A/B Testing
Dynamic URL redirect tests are the right approach in several common scenarios:
- E-commerce product page redesigns: Testing a new product page layout across your entire catalog without duplicating the experiment for each SKU.
- Category or collection page variants: Comparing a grid layout versus a list layout across all filtered category URLs (e.g., /category/shoes/*).
- Blog or content template tests: Running a new article template (/new-blog/*) against the existing one (/blog/*) across your full content library.
- Checkout flow variants: Redirecting users from /checkout/step1 to /checkout-v2/step1 while preserving dynamic order and session parameters.
- Landing page personalization: Testing personalized landing experiences where UTM parameters or campaign IDs are part of the URL pattern.
Dynamic URL Structure
If your goal is to redirect from https://www.example.com/product/laptop/12345 to https://www.example.com/product/laptop-test/12345 for every product — not only for the product 12345 — there is a very simple way to do it without creating thousands of experiment tests for each product ID.
All you need to do is use wildcard matching.
Just follow these 3 steps to quickly setup dynamic URL redirection:
Prerequisite: You will need to register a Mida.so account - it is totally free to get started for up to 100,000 monthly tested users.
1. Choosing test type

First, your test type should be Split URL / Redirect Test. Once you select that, make sure that you set up redirect rules for each of your variants - the versions of the element(s) that you're testing.
Choosing the correct test type matters because it determines how Mida assigns users to variants. For a redirect test, Mida stores the variant assignment in a first-party cookie on the visitor's browser, ensuring they always see the same variant on repeat visits — even if the exact URL changes slightly between sessions.
2. Setup redirection URL and wildcards

Now setup the Base Variation URL as the original link but replace the dynamic part with an asterisk (*). Then, setup variation 1 as /laptop-test/*.
For example, if your URL is https://example.com/blog/what-is-SEO and you wanted to test a new blog structure as https://example.com/new-blog/what-is-SEO, you can create the asterisked pattern as https://example.com/blog/* and https://example.com/new-blog/*.
The asterisk (*) is a wildcard that matches any character sequence in that position. When a visitor lands on a URL matching the control pattern, Mida captures the dynamic segment and maps it to the corresponding variant URL — keeping the unique identifier intact.
You can also use multiple wildcards in a single pattern. For instance, https://shop.example.com/*/id/* will match any combination of category and product ID, letting a single experiment cover your entire product catalog at once.
Free A/B Testing Tool
Run your next A/B test the right way
Visual editor, 15 KB script, GA4-native — and free forever up to 100,000 monthly visitors. No developer required.
3. Launching the test

That's it!
Your setup for an experiment between /laptop/(dynamic-ids) and /laptop-test/(dynamic-ids) is complete. You can now proceed to define the goal, allocate traffic and publish your test.
Before you launch, there are a few final checks worth doing:
- Define a primary goal: Set a conversion event — a purchase, a form submission, a click — so Mida has a clear metric to optimize toward.
- Set an appropriate traffic split: For most tests a 50/50 split is ideal. If you are testing a riskier variant, consider starting at 80/20 in favor of control.
- Check canonical tags: Ensure your variant pages include a canonical tag pointing back to the original URL. This prevents search engines from indexing the variant as a separate page.
Supported Patterns and Examples
To extend your grasp of what's possible with dynamic split URL testing, here are a few examples of supported patterns:
Setup scenario 1
Control matching pattern: https://example.com/blog/*
Variant 1 matching pattern: https://example.com/blog/*/v1
Variant 2 matching pattern: https://example.com/blog/*?v=2
Result #1
A user visited this URL, https://example.com/blog/what-is-seo
When variant 1 matched: https://example.com/blog/what-is-seo/v1
When variant 2 matched: https://example.com/blog/what-is-seo?v=2
Setup scenario 2
Control matching pattern: https://shop.example.com/product/*/id/*
Variant 1 matching pattern: https://shop.example.com/product/*/id/*-2
Result #2
A user visited this URL, https://shop.example.com/product/apple-watch/id/1133
Variant1 (when matched): https://shop.example.com/product/apple-watch/id/1133-2
A user visited this URL, https://shop.example.com/product/samsumg-galaxy-14S/id/4439
Variant1 (when matched): https://shop.example.com/product/samsumg-galaxy-14S/id/4439-2
SEO Considerations When Testing Dynamic URLs
One of the most common concerns teams have with redirect-based A/B testing is its impact on search rankings. The good news: Google explicitly states that A/B testing is allowed and will not result in a penalty — provided you follow a few technical rules. For a deeper dive, see our full guide on how A/B testing affects SEO.
Use Canonical Tags on All Variant Pages
When your variant URL (/laptop-test/12345) is a separate, indexable page, Google may crawl it and treat it as near-duplicate content compared to your original (/laptop/12345). To prevent this, add a canonical tag on your variant pages pointing to the original URL. This signals to search engines that the variant is a testing version, not a permanent destination worth indexing independently.
Mida Uses a JavaScript Redirect, Not a Server-Side 301 or 302
Mida performs the redirect entirely in the browser via JavaScript — the script detects the matching URL pattern and navigates the user to the variant URL using window.location.href. This means there is no HTTP 301 or 302 status code involved at the server level. The redirect is invisible to search engine crawlers because bots are excluded from the experiment entirely (see below). For search engines, your original URL remains the only URL they ever crawl and index.
Bots and Crawlers Are Excluded — and That Is by Design
Mida automatically excludes known bots and crawlers from redirect experiments. When a search engine crawler visits a page covered by a dynamic URL test, it sees the original control URL with no redirect — the same page your real visitors see when assigned to the control group. This means Googlebot always indexes the canonical version of your page, and you never have to worry about the crawler following a test redirect to a variant URL. Google explicitly approves this approach for A/B testing: excluding crawlers from variant delivery is not cloaking, because you are not serving deceptive content — you are simply keeping the test isolated to real human visitors.
Keep Tests Time-Limited
Running a redirect test indefinitely creates a persistent split between two URL patterns, which can confuse search engines over time. Most tests should conclude within 2–4 weeks once statistical significance is reached. Implement the winning version and retire the test promptly.
Dynamic URL Testing vs JavaScript-Based A/B Testing
Before setting up a redirect test for dynamic URLs, it helps to understand when this approach is the right fit versus a standard JavaScript-based A/B test on the same URL.
Use a dynamic URL redirect test when:
- The variant requires a completely different page template, route, or backend logic.
- You need the experiment to cover an entire URL family (thousands of product or article pages) with a single setup.
- The control and variant pages already exist as separate URLs and you want to split traffic between them.
Use a JavaScript-based A/B test on the same URL when:
- You are only changing visual elements — colors, copy, button placement, layout tweaks — on an existing page.
- You want the simplest possible SEO setup (one canonical URL, no redirect overhead).
- Your site is a single-page application where the browser does not issue new HTTP requests on navigation.
As a general rule: if the variant you want to test requires fundamentally different pages, use a redirect test. If you are changing elements on an existing page, a JavaScript-based test is simpler and carries less SEO overhead. You can learn more about split testing without changing the URL here.
Free A/B Testing Tool
Run your next A/B test the right way
Visual editor, 15 KB script, GA4-native — and free forever up to 100,000 monthly visitors. No developer required.
Best Practices for Dynamic URL Redirect Tests
- Start with high-traffic URL patterns: Wildcard tests work best when the URL pattern receives enough daily visitors to reach statistical significance within a few weeks. Test your highest-volume pages first to get results faster.
- Match the full pattern precisely: If your control is https://shop.example.com/product/*/id/*, make sure the wildcard positions map exactly to the right path segments in the variant URL. Mismatched wildcards will silently redirect visitors to incorrect pages.
- Test one major change at a time: The redirect should point to a meaningfully different version of the page — a new template, a different layout, a restructured information hierarchy. Avoid creating a redirect test for a small copy tweak; use a JavaScript test for that instead.
- Monitor page speed on variant pages: Your variant URL may be served by a different route with a different load profile. Check that it does not load meaningfully slower than the control, as page speed affects both conversions and SEO rankings.
- Segment by device type if needed: If your variant is optimized for mobile but not desktop, use audience segmentation in Mida to restrict the test to the relevant device type. Running a mobile-specific redesign against all traffic will dilute your results.
- Calculate your required sample size first: Before launching, use a sample size calculator to estimate how many visitors you need per variant to detect your expected effect size. This prevents you from running tests too long or cutting them too short.
Common Mistakes to Avoid
Creating Individual Experiments per URL
This is the most common beginner mistake. Creating a separate redirect experiment for every product ID in your catalog will exhaust your monthly tested user quota and make result analysis nearly impossible. Always use wildcard patterns to group URL families into a single experiment.
Not Setting a Conversion Goal
Launching a redirect test without a defined goal means you will have traffic data and no insight into which variant is actually better. Always configure at least one primary goal — purchase, form submission, button click — before publishing. Secondary goals such as scroll depth or time on page can supplement but should not be your sole measure of success.
Ending Tests Too Early
Redirect tests covering many dynamic URLs often accumulate traffic quickly, which can make early results look significant when they are not. Wait until your planned test duration is complete and statistical significance is confirmed before declaring a winner. Cutting tests short is known as the peeking problem and is one of the most common sources of false positives in experimentation.
Forgetting to End the Test After Shipping the Winner
Once you have a winner and you have implemented the change permanently on your site, stop the Mida experiment. Leaving a redirect test running after you have already shipped the winning URL creates unnecessary redirects for all visitors and continues to split traffic that should all be going to the canonical experience.
Frequently Asked Questions
Can I run a dynamic URL redirect test on a Shopify store? Yes. Shopify product URLs follow a consistent pattern (/products/[handle]), making them ideal for wildcard redirect tests. Set your control pattern to https://yourstore.myshopify.com/products/* and your variant to the new URL structure. Make sure Mida's script is installed via the Shopify theme or through a GTM container before launching.
Will dynamic URL redirect testing slow down my site? Mida's redirect happens in the browser before the variant page loads, using a lightweight script. The redirect itself typically adds only a few milliseconds of latency. The more relevant speed factor is whether your variant page is as fast as your control page — run both through PageSpeed Insights to compare before launching.
How do I verify that my wildcard pattern matched correctly?
Use Mida's built-in preview mode to visit a specific URL and confirm which variant you are assigned to. You can also open your browser's developer tools: if the redirect is working correctly, you will see the page navigate from the original URL to the variant URL — Mida performs this as a JavaScript redirect using window.location.href, so you will see the final variant URL in the address bar and in the network tab as the loaded document.
Can I test query parameter variations with dynamic URL redirect tests? Yes. You can include query parameters in your wildcard patterns. For example, testing /search?category=shoes&* against /search-v2?category=shoes&* will cover all filter combinations within that category. Be careful about parameter order — normalize your patterns to avoid gaps in coverage when the same parameters appear in a different sequence.
How is variant assignment kept consistent across multiple visits? Mida stores the variant assignment in a first-party cookie on the visitor's browser. Even if a user visits multiple dynamic URLs covered by the same experiment, they will always see the same variant. The assignment is visitor-level, not URL-level, so it persists across different pages within the same URL family.
Does dynamic URL redirect testing work for single-page applications (SPAs)? SPAs using client-side routing (React Router, Vue Router, etc.) handle URLs differently — the page does not fully reload on navigation, so the browser never issues a new HTTP request. In these cases a redirect test may not fire correctly. For SPAs, a JavaScript-based in-page test is usually more reliable. See Mida's SPA guide for details on how to run experiments on client-side rendered applications.
How many wildcards can I use in a single URL pattern? You can use multiple wildcards in a single pattern. For example, https://shop.example.com/*/category/*/id/* will match URLs with three dynamic segments. Each wildcard position in the control pattern maps to the corresponding position in the variant pattern, so the dynamic values are preserved correctly in the redirect.
Conclusion
Dynamic URL A/B testing is a powerful technique that lets you run experiments across your entire product catalog, content library, or checkout flow without creating individual tests for every URL. The key is using wildcard patterns to match URL families, pairing that with proper canonical tags on variant pages to protect your SEO, and letting experiments run until statistical significance is confirmed.
With Mida, the setup takes minutes — not days. You do not need engineering resources to implement wildcard redirect rules, and the same lightweight script that handles your standard A/B tests also powers dynamic URL experiments across thousands of pages simultaneously.
Ready to run your first dynamic URL experiment? Create a free Mida account and get started in under five minutes — no developer required.