-1

i'm from business and I would like to ask is it possible to create A/B test with dynamic part of URL?

API of backend application returns calculation ID for every visitor and its included on URL.

For example: We have main URL www.example.pl and I want to create A/B test with redirect to dynamic URL: www.example.com/calculation/(calculculation_id)

Is it possible?

Sergiusz
  • 11
  • 1
  • 1
  • Could you please clarify, what is the base url, and what would be the redirect url? Could you extend your example url with this. – kgrg Nov 08 '19 at 09:20
  • Thanks for your comment. The base URL is www.example.com/mortgage/static and redirect URL is www.example.com/calculation/11111, where "11111" is dynamic and get new number for every web visitor. When I want to redirect to URL I can't write static URL. – Sergiusz Nov 08 '19 at 10:15

2 Answers2

1

If your goal is to redirect from https://www.example.com/product/laptop/12345 to https://www.example.com/product/laptop-test/12345 for each product and not for the product 12345.

  1. Select test type redirect

  2. Set up redirect rules for each variant

  3. Customize your page targeting rules with "contains" or "starts with."

  4. Customize your advanced redirection"

1.Set up redirect rules for each variant

Find in domain/path com/product Replace with com/product-test

Add/modify query parameters/fragments (leave blank)

Original: https://www.example.com/product/laptop/12345

Redirect: https://www.example.com/product-test/laptop/12345 (see point 3.Customize your advanced redirection)

! Do not worry if you are entering the specific product 12345 this value seen by the system as variable xxxxx !

2.Customize your page targeting rules with "contains" or "starts with."

Modify the page targeting rules to ensure that we include any URL containing example.com/product.

3.Customize your advanced redirection.

In our example the text "com/product" is replaced with "com/product-test".

enter image description here

This is the site where you can find more information : https://support.google.com/optimize/answer/6361119?hl=en

Domenico Zinzi
  • 954
  • 10
  • 18
0

Yes, you can do that in different ways. I'd suggest using Feature Flags approach in your A/B test in order to have a flag to generated the dynamic next URL from the API.

I'll try to summarize in two steps that you should go:

  1. Add a Javascript in the Optimize Visual Editor for. Example here. The idea is this script to add a new flag:
    window.FeatureManager = window.FeatureManager || {};
    window.FeatureManager.variant_1_to_change_the_url = true;

enter image description here

  1. On your own script, look at this flag to call the backend API in order to get the calculated URL:
    // in case of the variant 1
    if (window.FeatureManager && window.FeatureManager.variant_1_to_change_the_url) {
      // calls the API passing this flag to get the new URL
      const redirectURL = fetch('my_endpoint', true/false); // true/false could be the variant verification
      location.href = redirectURL; // this is a sample, you can change the URL however you want
    } else {
        // the original variation
    }
BrTkCa
  • 4,703
  • 3
  • 24
  • 45