How to Create a Split URL Experiment That Adds a URL Query Parameter to the Variation?

This guide explains how to set up a Split URL experiment using regular expressions to effectively manage and direct web traffic by adding specific query parameters to URL variations.

Introduction

Split URL testing is an essential tool for website optimization, allowing you to compare different versions of a webpage by directing traffic to variant URLs. This guide will focus on using regular expressions (regex) to manage and direct URLs effectively in a Split URL experiment, specifically adding a query parameter to each variation.


Creating a New Split URL Experiment

  1. Create a New Experience

    • Go to your Experiment Dashboard and locate the "New Experience" button, typically in the top right corner. Click this to start the process of setting up a new experiment.
  2. Select Split URL Experiment

    • Choose the Split URL experiment type from the list of available options. Fill in the experience name and the URL of the Original site in the Visual Editor URL field.
  3. Configure Original and Variation URLs Using Regex and Add Variations

    • Original URL Pattern:

      • Use the following regex for the Original URL to capture the entire URL structure:
      ruby
      Copy code
      ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$

      This pattern decomposes the URL into components such as protocol, host, path, query string, and fragment, serving as the base for variations.

    • Variation URL Pattern:

      • Modify the captured groups from the Original URL regex to include a new query parameter, ensuring systematic addition without affecting other URL components:
      javascript
      Copy code
      $1$3$5?new_param=value&$7

      This adjustment appends a new query parameter (new_param=value), while retaining any existing query parameters.

    • Adding Variations:

      • Apply the defined regex pattern to set up the initial variation and add additional variations with a similar pattern to ensure consistency across tests. Name each variation clearly and add more variations if necessary using the plus icon. Traffic will be evenly distributed unless specified otherwise.
    • Example Scenarios:

      • Original URL without Existing Parameters:
        • Original: https://example.com/products
        • Variation: https://example.com/products?new_param=value
      • Original URL with Existing Parameters:
        • Original: https://example.com/products?category=books
        • Variation: https://example.com/products?category=books&new_param=value
  4. Configure the Experiment Location

    • Location Setup:
      • Define all potential Original URLs that will be part of the test. This includes specifying URL patterns or specific URLs where the experiment will run.
      • Ensure that the Experiment Location settings encompass all URLs that might receive traffic under the conditions of the test but exclude the Variation URLs. This is crucial to prevent the experiment from looping or affecting user experience by repeatedly redirecting to the variation.
    • Exclusion Note:
      • It is important to specifically exclude the Variation URL from the locations where the experiment is active. This prevents the added query parameters in the Variation URL from inadvertently triggering the experiment again, which could cause looping issues.
  5. Prevent Redirection Loops

    • To prevent redirection loops, ensure that your experiment’s location settings exclude URLs containing the new query parameter (new_param=value). This is crucial to avoid creating conditions that cause users to be redirected back and forth between variations, which can corrupt data and user experience.
  6. Verify Audience and Goals

    • Proceed to the Experience Summary to check and adjust the audience targeting for your experiment. Ensure the goals are properly set up to effectively measure the performance of variations against the original.
  7. Add Domains to the Project Configuration

    • If your variation URL's domain is different from the original, it must be added to the Project Configuration under "Active Websites" to ensure that the experiment runs correctly across all relevant domains.

Conclusion

Using regex in Split URL experiments facilitates precise manipulation of URL structures, allowing for detailed testing of web page variations with added query parameters. This method ensures accurate traffic direction and measurement, leading to more reliable and actionable insights.