Advanced targeting is a nice feature that gives you extra control over your ad campaigns. We will explain what options this feature has and how to use them in this short article.

Adserver.Online has the following advanced targeting options available:

  • URL substring – URL where ads will be displayed
  • Referrer substring – URL from where a visitor has come 
  • User-agent substring – User-Agent HTTP header from visitors' browser

Generally, the logic behind all these options is the same. The ad server finds occurrences of a substring in an ad request data and makes a decision whether to display an ad or not.

Field format

Substring is a comma-separated string. For example:

apple, orange, mango

Please note that the comma symbol means AND. Therefore, the expression above will be interpreted as "apple AND orange AND mango". So all words must be present to trigger ads display.

If you would like to use negative keywords, you need to place a hyphen (-) symbol before the keyword. For example:

apple, orange, -mango

As stated before, a comma symbol means AND. So this expression means "apple AND orange AND NOT mango"

Regular expressions

If you need more complex logic (including OR logic), you should use regular expressions.

In this case, a substring has to start from a tilde (~) symbol. Then it will be treated as a regular expression. We recommend that you double-check your regular expressions and test them here before using them in your campaign targeting.

For example, it can look like this:

~(apple|orange|mango)

In this case, ads will be displayed if either "apple" OR "orange" OR "mango" is present.

Advanced targeting examples

Let's say you have placed the same ad code on to several pages, for example:

  • http://example.com/blog
  • http://example.com/blog/post?id=1
  • http://example.com/blog/post?id=2
  • http://example.com/blog/post?id=3
  • http://example.com/about
  • http://example.com/shop

If you would like to display ads on "blog/post"  pages only, you should put this expression to "URL substring" field:

blog/post

When you want to display ads on all pages except "about" and "shop", you should use this expression:

-about, -shop

To display ads on "about" or "shop" pages only, you should use this regular expression:

~(about|shop)

If you wish to display ads on two particular posts, then you should use this regular expression:

~post\?id=(1|3)

To exclude the main page of the domain example.com, but still display ads on all other pages, then you should use this regular expression:

~^(?!.*example.com/$).*$

If you wish to display ads on the main page of the domain example.com only, then you should use this regular expression:

~^.*example.com/$

If you wish to exclude the Safari browser, then you should use this regular expression in "User agent substring" field:

~^(?!((?!Chrome|Android).)*Safari)

This should give you a basic understanding of how to use advanced targeting in your advertising campaigns. Though this feature might be very powerful, it's relatively easy to implement and doesn't need any coding experience. Use it wisely and don't forget to follow the instructions.