Rich-text Reply

Dynamic URLs

mark_beavers 05-12-14

Dynamic URLs

Hope someone can help.  We have a set of pages with this URL structure:


These pages show details about the indicated IP address. The IP address in the URL will change, so we will see many instances of these pages, such as:



Can Optimizely allow us to test a different layout, with this URL structure:



(Note the "IP-Details2" variant)






MJBeisch 05-12-14

Re: Dynamic URLs

[ Edited ]

Yes, use the "Substring" targeting method. That basically translates to: "if what I'm trying to target is contained anywhere in the URL, it's a match". You'd target against something like:


To set up Substring targeting, bring up your experiment in the editor. Under the "Options" menu on the right, pick "Targeting". That will bring up the URL Targeting settings for your experiment. The text box is where you place the URL text string to target against. The dropdown to the right of the text box is where you set the type of matching. That dropdown is where you would set the method to "Substring".


Edit: Oh hmm, it looks like you edited your post, and now my answer doesn't provide the full solution. Yes, it is possible to do something like that. You'd still have to do the substring matching as mentioned above, but would also have to set the variation up as a URL redirect with some scripting logic to inject the "2" into the redirected URL. The script would look something like this:


//Hide the body so it is not shown before redirect
$('head').append('<style>body {display:none}</style>');

/* _optimizely_redirect=http://custom */

/* Set the URL */
window.current_url = window.location.href;

//Replace IP-detials with IP-details2
window.location = window.current_url.replace("IP-details","IP-details2");

This code should work based on the details that you've given so far, but may not be 100% accurate if there are other possible valid URLs that you have not described. In a nutshell, what you'd setting up (if following the above instructions) is an experiment that watches for any traffic to the IP-details page then redirecting it to the corresponding IP-details2 page.

Matt Beischel - E-Commerce Optimization Specialist CohereOne

Level 2