close this to read article
Custom URL in VWO allows 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:
- 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 a wildcard (*) pattern such that you can run a test on more than one page of your website.
For example, if you wish to match all the pages of your website www.example.com, specify the URL pattern as www.example.com*. To learn about the different URL patterns supported by VWO, refer to URL Patterns in VWO. - Website pages that do not have a pattern: If the pages you want to test do not have a consistent pattern, either a regular expression and if even that is not available, you can use a Custom URL feature to run your test across the 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 you want to test.
Setting Up a Custom URL For Your Test
Procedure
- Create an imaginary custom URL for the pages you want to test. The custom URL is only an identifier in the test and does not need to exist in real life. For example, the imaginary custom URL could be http://example.com/my_shoes_pages.
- Enter the custom URL you created while setting up the test in VWO. Refer to the following screenshot as an example:
- Add the custom URL to the _vis_opt_url JavaScript variable of your VWO SmartCode. Add the variable to all the pages which you want to include in the test.
Modify the VWO Asynchronous SmartCode to Implement Custom URL
For tests using VWO asynchronous SmartCode, modify the code snippet to add the custom URL to the _vis_opt_url variable as follows:
NOTE: Ensure to replace encodeURIComponent(d.URL) with encodeURIComponent(_vis_opt_url) in the SmartCode.
ATTENTION: Do not add “var _vis_opt_url = ‘http://example.com/my_shoes_
pages’+ location.search + location.hash;” within the VWO SmartCode(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.
To check if you have correctly installed the SmartCode on your webpage, enter the URL in the SmartCode Checker in the Settings > SmartCode section of your VWO Account. See SmartCode Checker in VWO to know what different results mean.
Modify the VWO Synchronous SmartCode to Implement Custom URL
To implement the custom URL, there are two implementations in which you can modify the VWO Synchronous SmartCode:
- If you’re using the One SmartCode (synchronous SmartCode), use the following code and modify this code snippet to add the required custom URL to the _vis_opt_url variable given here:
NOTE: This code needs to be added before the One SmartCode (synchronous SmartCode) code.
- If you’re still using the deprecated synchronous SmartCode implementation, use the following to modify the code snippet to add the custom URL to the _vis_opt_url variable:
NOTE: Ensure to replace encodeURIComponent(d.URL) with encodeURIComponent(_vis_opt_url) in the SmartCode.