Rich-text Reply

site-wide test with url parameter

ilincev 05-06-16
Accepted Solution

site-wide test with url parameter

Hi,

I have a site with a form. This form is on multiple pages. I am showing a version B of the form via a url parameter (?demoversion=b). How do I setup Optimizely to run on all the pages (regex?) and show both versions?

Ondrej Ilincev
conversion optimizer
Level 3

JasonDahlin 05-06-16
 

Re: site-wide test with url parameter

@ilincev - Does the alternate form appear only if the parameter is in the URL?

 

If the alternate form only shows when the parameter is present, you will need to set up your experiment so that it targets every URL that the form is on (use RegEx, a list of URLs for "Simple Match", etc.  whatever works).  For each of these URLs, the B variation will need to redirect back to the same URL but with the new parameter present.

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
ilincev 05-06-16
 

Re: site-wide test with url parameter

Yes. How do I setup the redirect for the same url but with a parameter?
Ondrej Ilincev
conversion optimizer
Level 3
JasonDahlin 05-06-16
 

Re: site-wide test with url parameter

[ Edited ]

Hi Ondrej,

 

1- set up your experiment so that it tagets the pages that you need targeted.  Since you are adding a URL parameter when a user is redirected, you can exclude URLs that contain the parameter from the experiment using "substring match" on "demoversion=b"

2- when you set up the "B" variation, choose "Redirect to a new page..." and click "Apply"

3- edit the B variation's code so that it resembles the following:

 

/* _optimizely_redirect=http://custom */
/* _optimizely_evaluate=force */
	var newURL = window.location.protocol + "//" + window.location.host + window.location.pathname;
	if (window.location.search.length > 0) {
		newURL += window.location.search + "&demoversion=b";
	} else {
		newURL += "?demoversion=b";
	}

	var _optly={redir:document.createElement("a")};
	_optly.redir.href=newURL;

	if (_optly.redir.href !== '') {
		window.location.replace(_optly.redir.href);
	}
/* _optimizely_evaluate=safe */

 

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
ilincev 05-09-16
 

Re: site-wide test with url parameter

Regarding the targeting.... the form is on almost all the pages apart from pricing and thank you. I guess I can target the whole site with a simple match and then remove specific urls with an exact match. And remove the url parameter with a subscring match as well. Will this work?
Ondrej Ilincev
conversion optimizer
Level 3
JasonDahlin 05-09-16
 

Re: site-wide test with url parameter

@ilincev - Yes.

But... Can your dev team make the form switch to the other one without the URL parameter?  Having almost every page on your site redirect just to add the parameter will probably be noticed by your users.  It would be preferable if the pages could load with both forms present (but one of them invisible) so all you have to do is add CSS that renders the default form invisible and the test form visible.  If it's too late for adjustments to execution, then what we've discussed so far will work - redirect all page to the same URL but with the parameter (excluding pages where you know you don't need to redirect - like pricing, thank you, and pages that already have the parameter).

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
ilincev 05-10-16
 

Re: site-wide test with url parameter

[ Edited ]

I have setup the url targeting for substring match of the whole domain (www.example.com) and excluded a couple of pages (simple match) and the url parameter ?demoversion=b (substring match). Weirdly when I preview the test, the original url is ok, then I switch to the variation, url still ok. But when I switch back to the original I still see the url parameter (?demoversion=b).

 

Is there an infinite loop with the original and variation? Can you help out?

Ondrej Ilincev
conversion optimizer
FireShot Screen Capture #402 - 'Redmine plugins, hosting, solutions - Easy Redmine' - www_easyredmine_com__optimizely_show_preview=true&optimizely_token=ec53fa7dd775bb12dd219baa77d3f3523dfcd1c1c2ace22061133b4641c9c74.jpg
Level 3
JasonDahlin 05-10-16
 

Re: site-wide test with url parameter

@ilincev - The setup for experiment 5884520236 appears correct.

 

When you switched to the B variation using the preview plugin, the variation code ran and redirected you to the same URL but with the parameter.  Switching the plugin back to "Original" at this point does not cause you to go back to the previous URL.

 

While you have the preview plugin tool set to "Original" and you go to a page that does not have the demoversion parameter, is it redirecting you?  If not, everything is perfect.

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
ilincev 05-10-16
 

Re: site-wide test with url parameter

When I switch to the original and delete the url parameter, the page shows the original variation. Great. I have been pulling my hair out trying to figure this out. Thank you so much for your help.

Ondrej Ilincev
conversion optimizer
Level 3
ilincev 05-11-16
 

Re: site-wide test with url parameter

One more thing. I just found out that the redirect deletes any # anchors. How do I update the redirect script to keep them in the url.

Example:

original url - www.example.com/product#1

current redirect goes to - www.example.com/product?demoversion=b

ideal url - www.example.com/product#1?demoversion=b

 

Can you help please?

Ondrej Ilincev
conversion optimizer
Level 3
JasonDahlin 05-11-16
 

Re: site-wide test with url parameter

[ Edited ]

@ilincev - Those darn hash values - I always forget about including them.

 

/* _optimizely_redirect=http://custom */
/* _optimizely_evaluate=force */
	var newURL = window.location.protocol + "//" + window.location.host + window.location.pathname;
	if (window.location.search.length > 0) {
		newURL += window.location.search + "&demoversion=b";
	} else {
		newURL += "?demoversion=b";
	}

	newURL += window.location.hash;

	var _optly={redir:document.createElement("a")};
	_optly.redir.href=newURL;

	if (_optly.redir.href !== '') {
		window.location.replace(_optly.redir.href);
	}
/* _optimizely_evaluate=safe */

 

--Jason Dahlin
Analytics and Testing Guru Smiley Happy