Rich-text Reply

Can Optimizely add a parameter to a URL that already has a parameter?

Evanson509613 01-05-15

Can Optimizely add a parameter to a URL that already has a parameter?

[ Edited ]

I am trying to set up a test to remove one of my CTA's that is across the site. When I did this with the "remove" attribute in the editor and started the experiment, we noticed about a 2-3 second window between the page loading and the CTA disappearing.

 

To avoid this, we wanted to add a parameter through the Optimizely redirect option that we can then target in our code to tell the page to hide the button behind the scenes so no "flashing" is seen by our users.

 

I have figured out how to add the parameter to the URL, but now my problem is that on one page of my site there is already parameters in the in URL, and the new parameter that Optimzely is adding (?ViewMode=1) is not displaying correctly with this URL. The new parameter is displaying as the first parameter in the query string, and therefore, there are two '?', instead of adding itself at the end with the &.

 

Currently the URL looks like:

http://www.example.com/?ViewMode=1?z=1&example=2

 

What I would like it to look like:

http://www.example.com/?z=1&example=2&ViewMode=1

 

Can anyone help me with this?

 

Thanks,

Samantha

JDahlinANF 01-05-15
 

Re: Can Optimizely add a parameter to a URL that already has a parameter?

If all you want to do is add a "&z=1" param to the current URL, you can run this code.

/* _optimizely_redirect=http://custom */
/* _optimizely_evaluate=force */
	var _optly={redir:document.createElement("a")};
	_optly.redir.href=window.location + '&z=1';
	window.location.replace(_optly.redir.href);
/* _optimizely_evaluate=safe */

 

You should alter your URL targeting to exclude pages with the "z=1" URL parameter.

 

Separately, what code are you using to make the CTA disappear?  There may be tweaks that can be made that make it disappear quicker.