0

We are trying to run a Redirect Test with Google Optimize on our booking page. So basically there are two different page that we want to test. But each page, has two different URL. One for create and another for edit.

For example:

  1. Variant A

  2. Variant B

So basically we want to create a test that when users visit whether create or edit url they will be redirected to the variant they get respectively.

Let's say I get Variant A from the beginning. So when I visit create page, I will be redirected to Variant A create page. And when I visit edit page, I will also be redirected to Variant A edit page. This rule also apply if I get Variant B.

Is this possible to implement in a single Google Optimize Redirect Test? Or any other suggestion that can achieve this?

Thanks in advance.

d-_-b
  • 21,536
  • 40
  • 150
  • 256
IrvanFza
  • 180
  • 2
  • 15

1 Answers1

1

You could achieve this with custom Javascript in your variation code.

  1. Edit variation
  2. Choose Select elements
  3. enter head as the selector
  4. Click Add Change and select Javascript
  5. Enter the javascript code to redirect accordingly

An example of that script might be (and there are many, many ways you might want to code this):

switch(location.pathname){
  case '/create/booking/a':
    location.assign('/create/booking/b'); 
    break;

  case '/create/edit/a':
    location.assign('/create/edit/b');
    break;

  default:
      console.log('Here is a scenario you forgot about, or the URL targeting is too broad');
}

example javascript

Step 1

d-_-b
  • 21,536
  • 40
  • 150
  • 256
  • Actually, I already implement it with almost the same approach you describe, but I use GTM instead. As on this tutorial: https://www.youtube.com/watch?v=04EI8MWvEAY. And I add redirection inside the variant. But there is flickering problem like before redirecting, the browser show actual page first. Your solution might solve this. Thanks! – IrvanFza Apr 02 '19 at 09:25
  • This will be difficult to solve 100% perfectly, but you can add the hiding classes to your page: https://developers.google.com/optimize/. This would hide the entire `body` until (a) optimize loads, or (b) page loads completely - whichever is first. – d-_-b Apr 02 '19 at 18:04