This website works best with JavaScript enabled. Learn how to enable JavaScript.

Using Custom URL to Run a Site-Wide Test

Last updated

Custom URLs allow you to test multiple pages of your website even if the website pages do not have a consistent pattern. Typically, running a VWO test across multiple pages on your website involves the following two scenarios:

  1. Website pages that have a consistent pattern: To run a test across multiple pages, specify a URL pattern while creating a test. URL patterns allow you to specify wildcard (*) patterns so that you can run a test on more than one page of your website.
    For example, to match all pages of your website, specify the URL pattern as http://www.example.com*. Click here to know more about using a URL pattern.
  2. Website pages do not have a pattern: If the pages you want to test do not have a consistent pattern, use the Custom URL feature to run the test across website pages.
    For example, consider that you have the URLs, http://example.com/adidas/, http://example.com/reebok/, http://example.com/microsoft/, and http://example.com/adobe/. You want to run the test on pages that list shoe brands (Adidas and Reebok in the example). The URLs of the webpages do not have a proper pattern; therefore, we use the Custom URL feature to specify the pages we want to test.

Follow these steps to set up a custom URL test:

  1. Create an imaginary custom URL for the pages you want to test. The custom URL is only an identifier in the test and need not exist in real. For example, say the imaginary custom URL is http://example.com/my_shoes_pages.
  2. Type the custom URL you created while setting up the test in VWO. Refer to the following screenshot as an example:
    custom-url
  3. Add the custom URL to the _vis_opt_url JavaScript variable of your VWO smart code. Add the variable to all the pages which you want to include in the test.
    var _vis_opt_url = 'http://example.com/my_shoes_pages'+ location.search + location.hash;

Modify VWO Asynchronous code to implement custom URL

For tests using VWO asynchronous code, modify the code snippet to add the custom URL to the _vis_opt_url variable, as follows:

<script type="text/javascript">

// Only on pages where this test is to be run

var _vis_opt_url = 'http://example.com/my_shoes_pages'+ location.search + location.hash;
var _vwo_code=(function(){

var account_id= ACCOUNT_ID, // your Visual Website Optimizer Account ID

_vis_opt_url = window._vis_opt_url || document.URL,

settings_tolerance=2000, library_tolerance=1500, use_existing_jquery=false, … … …

this.load('//dev.visualwebsiteoptimizer.com/j.php?a='+account_id+'&u='+encodeURIComponent(_vis_opt_url)+'&r='+Math.random()); … …

</script>

Important: Do NOT add “var _vis_opt_url = ‘http://example.com/my_shoes_pages’+ location.search + location.hash;” within the VWO smart code (within var _vwo_code=(function(){…). Keep the custom URL variable separately in its own script tag or before the var _vwo_code=(function(){.., as displayed in the code example.

Modify VWO Synchronous code to implement custom URL

For tests using VWO synchronous smart code, modify the code snippet to add the custom URL to the _vis_opt_url variable as follows:

<script type="text/javascript">

// Only on pages where this test is to be run

var _vis_opt_url = 'http://example.com/my_shoes_pages'+ location.search + location.hash;

… … …

// Common VWO Code

var _vis_opt_url = typeof(_vis_opt_url)=="undefined" ? document.URL : _vis_opt_url;

…. '&url='+encodeURIComponent(_vis_opt_url) +'&random='+Math.random()

Was this article helpful?

Thanks for your feedback!
Please email us at support@vwo.com to tell us what you were looking for. We'll send the answer to your inbox.

Contact Us / Login