• Page targeting

    Table of contents

    In short

    With the help of page targeting, you can determine on which pages of your website an experiment should be displayed. In the settings of your experiment, you will find various options under "Page targeting" to control your experiments based on rules. Correctly configured page targeting is also a prerequisite for starting an experiment.

    Page targeting options

    You can use rules to define the pages or page types on which your visitors become experiment participants. You have several options for identifying pages.

    You can use rules to define the pages or page types on which your visitors become experiment participants. You have several options for identifying pages.

    The use of the CSS Selector is useful if you want to target several pages, but these cannot be clearly identified via URL rules. 

    You can use JavaScript to define more complex targeting rules. For example, you also have the option of checking for special DataLayer entries.

    URL Match

    With the URL match, you use URL rules to define the pages on which your experiment is displayed. You can define several URL rules that should or should not apply.

    Linking several URL rules

    You can apply several URL rules at the same time and link them together. To do this, you can enter different URLs using the plus symbol. Use URL "matches" or "does not match" to set whether the experiment should be displayed or not displayed on the URLs entered.

    If you want to apply more complex targeting rules, for example: The expeirment should be displayed on all pages of https://www.demo.de, except on https://www.demo.de/impressum, then you can also link several URL matches together. 

     

    Matching Type

    To the right of the input field, you can specify the matching type of your targeting condition. Depending on the selection, the URL in the input field next to it is checked for various conditions. You have the following conditions to choose from:

    • Simple Match
    • Exact Match
    • Contains
    • Regex  

    The targeting conditions with application examples are explained in more detail below. 

    Simple Match

    At the Simple Match all URLs are targeted, including the associated URL parameters. 

    In the following example, you can see the versions of a URL that are used for page targeting Simple Match for the URL www.demo.de apply:

    URL Targeting applies
    www.demo.de
    applies
    www.demo.de#about
    applies
    www.demo.de?color=red
    applies
    www.demo.de/category
    does not apply
    www.demo.com
    does not apply
    sub.demo.com
    does not apply

    If you want to target multiple pages, page types or subdomains at the same time, you have the option Regex. Just read on.

    Exact Match

    Use the condition Exact Matchif the page targeting explicitly only for a specific URL - without URL parameter - should apply.

    In the following example, you can see the versions of a URL that are used for page targeting Exact Match for the URL www.demo.de apply:

    URL Targeting applies
    www.demo.de
    applies
    www.demo.de/
    does not apply
    www.demo.de#about
    does not apply
    www.demo.de?color=red
    does not apply
    www.demo.de/category
    does not apply
    www.demo.com
    does not apply
    sub.demo.com
    does not apply

    Contains

    The page targeting condition Contains you use when you several pages of a certain group you want to target. For example, if you want to run a test on product pages only, you could use "Contains" with "/products/" to include only these pages. The complete specified expression must appear at least once in the URL.

    In the following example, you can see different versions of URLs where the page targeting "/products/" applies.

    URL Targeting applies
    www.demo.de
    does not apply
    www.demo.de/produkte
    does not apply
    www.demo.de/produkte/t-shirts
    applies
    www.demo.de/produkte/hosen
    applies
    www.demo.de/blog/produkte-reviews
    does not apply
    www.demo.de/blog/produkte/tests
    applies

    Regular Expressions (Regex)

    Regular expressions allow you to set your A/B tests to specific individual pages or page groups to target specifically. This may be more precise than, for example, with the targeting conditions just presented.

    We have created this guide to page targeting with regex to make it easier for you to get started with regex. In many cases, it is sufficient to copy one of our examples and replace your own URL.

    To validate your regular expressions you can use regex editors like regexr.com.

    Example of creating a regex

    On Plomo-o-Plata on all product detail pages in the category Outlet Sale the sales prices will be displayed in red. Product detail pages in other categories should remain unchanged.

    By using regex in URL targeting you have the possibility to explicitly map this targeting condition.

    As an example, here you can see a URL that is located in the Outlet Sale category.

    https://plomo-o-plata.de/collections/plomo-o-plata-outlet-sale/products/plomo-o-plata-bandeau-leo-foulard-gruen

    The structure of the URLs is the same for all product detail pages that can be found in this category:

    https://plomo-o-plata.de/collections/plomo-o-plata-outlet-sale/products/…

    In the table Useful use cases you will find predefined regexes that you can apply to your website URL structure using this example. In our case, use case 3 applies.

    -> Targeting of all pages that are www.demo.de/category/ after the path.

    -> ^.*www\.demo\.de\/category\/.+

    First, we go to https://regexr.com/ and transfer the similar use case.

    We can now use this use case as a guide, and apply it to our example of Plomo-o-Plata. 

    In the screenshot you can see how we customized the regex to our use case. Since the URL of Plomo-o-Plata had two more directories than the use case, they were added analogously to the use case example. Another very useful tool to define regex is: https://www.autoregex.xyz/ Here you can define in English which page types should be targeted. The tool converts this specification into a regex.

    Useful use cases

    Use case Example page Regular Expression
    Targeting exactly one page
    www.demo.de/product-list
    ^.*www\.demo\.de\/product-list$
    Targeting exactly one page incl. anchor links, parameters, and optional "/"
    www.demo.de/?utm_source=google_cpc
    ^.*www\.demo\.de(#.*|\/#.*|$|\/$|\/\?.*)
    Targeting of all pages hung in the path www.demo.de/category/
    www.demo.de/category/product
    ^.*www\.demo\.de\/category\/.+
    Global targeting of a page without "www."
    demo.de/
    ^.*demo.de\/.*
    Global targeting on the entire domain www.demo.de/
    www.demo.de/
    ^.*www\.demo.de\/.*
    Targeting on a subdomain blog.demo.de/
    blog.demo.de/category/article
    ^.*blog\.demo.de\/.
    Targeting on an entire domain incl. subdomains demo.de/
    blog.demo.de/category/article www.demo.de/category/product
    ^.*demo.de\/.*
    Targeting on two specific product categories
    www.demo.de/shirts/product www.demo.de/pants/product
    ^.*www\.demo.de\/(shirts|pants)\/.*

    Need help setting up your regex? No problem!

    Just send us a message with the page group you want to target. We will send you the appropriate regex as soon as possible.

    Targeting via CSS Selector

    Only target pages or page types on which there is a specific element with a unique CSS selector. For example, you want to target all product detail pages of your online store in an experiment, but there is no reference such as "/products/" in the URL that allows you to make this assignment. In such a case, you could look for an element that is only available on the product detail pages, such as the "Add to cart" button. You can then use the corresponding CSS selector for this button in page targeting.

    The easiest way to determine a unique CSS selector is to open one of the relevant pages in the Varify visual editor. Then click on the element that only appears on this specific page type. You can then copy the CSS selector displayed and paste it into Page Targeting under 

    Targeting via JavaScript

    For more complex page targeting, you can use JavaScript. In this way, you can also search for any tags or attributes in the DOM of your website. JavaScript also allows you to check data from data layer variables.

    Application example - Data layer entry

    To target only users who have a certain parameter or a certain value in the data layer, you can navigate through the data layer. In the following example, only users who have previously viewed a specific product with ID 1111 or ID 2222 are targeted.

    Code example - Data Layer Targeting
    				
    					return dataLayer?.some(item => item?.ecommerce?.checkout?.products?.[0]?.id==='1111' || item?.ecommerce?.checkout?.products?.[0]?.id==='2222');
    				
    			

    Advanced Settings

    Cleanup Experiment on URL change

    Websites that dynamically reload content - such as single page applications (SPAs) or online stores that offer several product variants on the product detail page - behave differently to traditional static pages. With static pages, all content is completely reloaded each time the URL is changed. With SPAs and similar dynamic websites, on the other hand, only the content that changes is updated.

    Behavior with URL changes

    By default, Varify performs a reset of the variant playout every time the URL is changed, i.e. all variations on the page are reset, the URL is checked again and all applicable variations for the new URL are reapplied.

    Deactivation of the standard function

    Deactivating the "Cleanup Experiment on URL change" function can be particularly useful on product pages in online stores where you can select different product variants such as colors. With such a selection, the URL may change to reflect the selected color. However, if there is a variation that relates to content that does not change (for example, the "Add to cart" button), it would not be desirable to delete and reapply this variation. This could lead to undesirable effects such as screen flickering.

  • First steps