# How to use URL operators to build URL patterns

## Definition <a href="#h_01hvvackcrdkhqebedyfk4abf1" id="h_01hvvackcrdkhqebedyfk4abf1"></a>

In this article, we'll take a look at the **different operators** for building **URL patterns** and how you can manipulate and mix them to recreate **URL pattern rules** that meet your needs.&#x20;

**URL patterns are rules that allow you to create groups of URLs that share these rules.** They're mandatory to declare your campaigns' targeting, create specific [**segments**](/assets-library/creating-and-managing-segments.md) or [**triggers**](/assets-library/creating-and-managing-triggers.md) and of course create [**saved pages**](/assets-library/creating-and-managing-saved-pages.md) and map your website.&#x20;

For example, if I want to create an URL pattern "all product pages", I will identify what's in common in all the product pages of my website to build the rule. Here it could be `contains` `/product/`

The URL template needs to be **as inclusive as possible**, to make sure that 100% of the product pages on my website match the rule, in our example. But at the same time, the URL model must **also be exclusive**, to ensure that pages that aren't product pages don't match the rule.

To build these rules, we offer **8 operators** that should enable you to create all the URL patterns you need to map your website.

## Operators <a href="#h_01hvvackcrvy9pcrxjjn2m72f1" id="h_01hvvackcrvy9pcrxjjn2m72f1"></a>

This is the list of operators available to build your **URL patterns**:

| **Operator**                  | **Functional: accepts...**                                                                                                                                                                                                                                                                                                                              |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **is**                        | <p>Includes <strong>all URLs matching the string</strong>, even if they <strong>include</strong> <strong>parameters</strong>. </p><p>⚠️ With this operator, the page is targeted no matter which parameters are included in the URL. Therefore, you cannot write any particular parameter in this field.</p><p>Example: <https://mydomain.com/cart></p> |
| **is exactly**                | <p>Includes <strong>the unique URL matching the exact string</strong>. Parameters that are not mentioned in the string <strong>are not taken into account</strong>. </p><p>💡 This field <strong>accepts parameters</strong> as an option.</p><p>Example: <https://mydomain.com/cart>?<em>news</em></p>                                                 |
| **contains**                  | <p>Includes <strong>all URLs containing the string</strong>. Parameters following the string will also be taken into account.</p><p>Example: /product/</p>                                                                                                                                                                                              |
| **is regular expression**     | <p>Includes <strong>all URLs matching the regex</strong>. You don’t need to escape special characters of your regular expression.</p><p>Example: <em><https://www.example.com></em></p><p>/products/(.\*)--(\[0-9]{5})</p>                                                                                                                              |
| **is not**                    | <p>Excludes <strong>all URLs matching the string</strong>, even if they <strong>include</strong> <strong>parameters</strong>. </p><p>⚠️ This field doesn’t accept parameters.</p><p>Example: <https://mydomain.com/cart></p>                                                                                                                            |
| **is not exactly**            | <p>Excludes <strong>the URL matching the exact string</strong>.</p><p>💡 This field accepts parameters as an option.</p><p>Example: <https://mydomain.com/cart></p>                                                                                                                                                                                     |
| **does not  contain**         | <p>Excludes <strong>all URLs containing the string</strong>. Parameters following the string will also be taken into account.</p><p>Example: /product/</p>                                                                                                                                                                                              |
| **is not regular expression** | <p>Excludes a<strong>ll URLs matching the regex</strong>. You don’t need to escape special characters of your regular expression.</p><p>Example: <https://www.example.com></p><p>/products/(.\*)--(\[0-9]{5})</p>                                                                                                                                       |

## Mixing inclusions and exclusions <a href="#h_01hvvackcrvy9pcrxjjn2m72f1" id="h_01hvvackcrvy9pcrxjjn2m72f1"></a>

**Inclusion(s) only in your URL pattern**

If you include one or several specific URL(s) entirely, all the other URLs which don't match the rule will automatically be **excluded** from the URL pattern rule. **To be accepted to the rule, an URL will have to match at least one of them.**

***Exemple: URL Pattern "checkout"***

Includes the following conditions:

*is* [www.mywebsite.com/basket](http://www.mywebsite.com/basket) **OR** [www.mywebsite.com/delivery](http://www.mywebsite.com/delivery) **OR** [www.mywebsite.com/payment](http://www.mywebsite.com/payment) **OR** [www.mywebsite.com/thankyou](http://www.mywebsite.com/thankyou)

This URL pattern will accept all the pages of the checkout without any exception, whatever some parameters are added in the URL, and won't accept any other page of the website.

You can decide whether you want **all conditions to be met**, **or at least one**. This is the difference between the `some` and `all` options.

In our exemple, with entire URL, the ***some*** option should be chosen.

### **Combination of inclusions and exclusions**  <a href="#h_01j5zmpdgn2prqfddbd0a1t6nk" id="h_01j5zmpdgn2prqfddbd0a1t6nk"></a>

You can combine inclusive operator(s) (`is`, `is exactly`, `contains`, `is regular expression`) with exclusive operator(s) (`is not`, `is not exactly`, `does not contain`, `is not regular expression`). \
In this case, to be accepted in the pattern rule, a website’s URL has to match:

* **`All`** **the exclusion rules**
* **`Some` (at least one) of the inclusion rules**

***Exemple: URL Pattern "All pages except checkout"***

Includes the following conditions:

***contains*** [www.mywebsite.com](http://www.mywebsite.com)

**`AND`**

**`is not`** [www.mywebsite.com/basket](http://www.mywebsite.com/basket) **`AND`** [www.mywebsite.com/delivery](http://www.mywebsite.com/delivery) **`AND`** [www.mywebsite.com/payment](http://www.mywebsite.com/payment) **`AND`** [www.mywebsite.com/thankyou](http://www.mywebsite.com/thankyou)

{% hint style="info" %}
**⭐ Good to know**

**Adding exclusions only in a pattern rule is not possible.** To work properly, the rule has to be filled with almost one inclusion condition. Otherwise the rule will never work with any URL. If you want to add one or several exclusions, you need to add at least one inclusion (the entire website for example).&#x20;
{% endhint %}

## Use cases <a href="#h_01hvvackcrjgwzdj0k0gpnfmre" id="h_01hvvackcrjgwzdj0k0gpnfmre"></a>

Here are some examples of configuration, depending on the pages of your website you want to target:

| **Target the homepage of your website** |                                                                                                                                                                                                                                                                                                                                                                               |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL operator                            | is                                                                                                                                                                                                                                                                                                                                                                            |
| URL                                     | <http://mydomain.com>                                                                                                                                                                                                                                                                                                                                                         |
| Result                                  | The modified page will be seen by your visitors, including those being redirected from partner websites or having clicked on sponsored links. In this case, the URL displayed in their browser is followed by UTM or other tracking parameters. However, AB Tasty recognizes the URL regardless of the parameters linked to it and displays changes to the relevant visitors. |
| Example of a URL                        | You will target the <http://mydomain.com> page, as well as <http://www.mydomain.com/?utm\\_medium=email> and even <http://www.mydomain.com/?utm\\_medium=cpc>.                                                                                                                                                                                                                |

| **Target all category pages of your website** |                                                                                                                                                                                                                                                                                                             |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL operator                                  | Contains                                                                                                                                                                                                                                                                                                    |
| URL string                                    | /category/                                                                                                                                                                                                                                                                                                  |
| Result                                        | <p>  The changes are applied to all pages for which the AB Tasty platform has identified the common section of URL.</p><p>You must make sure non-desired pages aren't included by mistake because they contain the same section of URL: as a safety precaution, you may use a regular expression.      </p> |
| Example of a URL                              | You will target the <http://mydomain.com/category/page1> page, but also <http://mydomain.com/category/page1/article.html>.                                                                                                                                                                                  |

| **Target all the product pages of your website.** |                                                                                                                                                                                                                                                               |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL operator                                      | Is regular expression                                                                                                                                                                                                                                         |
| Full URL                                          | <p>  <http://www.example.com/products/(.*)--([0-9]{5})></p><p>  (For example if your URLs match the following format:   <http://www.example.com/products/product-name--12345>, where 12345 coincides with a 5-digit product ID)</p>                           |
| Result                                            | A regular expression enables you to use a strict writing rule to define the pages to be targeted. This guarantees that you will include only the pages that need to be, particularly if your pages share a structure and include a set of digits and letters. |
| Example of a URL                                  | <p>  You will target the <http://www.example.com/products/shoes-children--96753.html></p><p>  or <http://www.example.com/products/garden-furniture--13082> pages.</p>                                                                                         |

## Focus on *All* and S*ome* operators <a href="#h_01j5zjk0eahh2dg6rh8ggj803n" id="h_01j5zjk0eahh2dg6rh8ggj803n"></a>

**`All`** and **`Some` operators** enable you to combine several conditions within a set-up in the targeting step such as a segmentation or a triggering criterion. They appear in a drop-down list when two or more conditions are added. In most cases, both `All` and `Some` operators are available.

| **Operator** | **Definition**                                                | **Example**                                                                                     |
| ------------ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| **Some**     | The set-up matches **at least** one of the conditions.        | In the Geolocation criterion: target visitors located either in France OR in the United States. |
| **All**      | The set-up matches **all** the conditions, without exception. | In the Content interest criterion: target visitors interested in BOTH *skirt* and *dress*.      |

&#x20;

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.abtasty.com/web-experimentation-and-personalization/targeting-step/how-to-use-url-operators-to-build-url-patterns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
