Referrer URL audience condition: Include and exclude visitors by search term

  • Updated
This topic describes how to:
Use the Referrer URL audience condition to include and exclude visitors in your experiments by search term.

The Referrer URL audience condition option allows you to to trigger an experiment based on the URL that your visitors came from. This is commonly known as the referrer.

Typical use cases include setting audiences by the search engine they use, or excluding certain promotional referrers. The match types used for Referrer URL audience conditions are the same as the match types used for URL Targeting in Optimizely Web Experimentation.

For more advanced referrer targeting, you can capture a search term that led the visitors to your page. This requires limiting the URL match to a Regular Expression (regex) match to capture the search terms as provided by the various search engines. This will work for Yahoo and Bing, but not Google, because Google does not use the 'q' parameter.

The example below shows what this might look if you are interested in targeting an experiment for any visitor that came to your page by entering the keyword "example" into their search engine:

  • http://search\.yahoo\.com/.*(p=.*example).*toggle
  • http://www\.bing\.com/.*(q=.*example).*go

The recorded referrer URL is the initial referrer or the originating URL. This can be further defined as the URL of a page outside the domain of the snippet that the visitor navigated from before landing on a page where the snippet is implemented.  

The referrer URL is defined by Optimizely Web Experimentation at the time when a visitor first comes in contact with the snippet, not an experiment. Even if there is no experiment present at the time the visitor comes in contact with the snippet, the visitor object recognizes the URL from the previous domain page a visitor migrated from.

When troubleshooting this issue, use the visitor object from the JavaScript API: window["optimizely"].get("visitor");

Look under events to find what URL Optimizely Web Experimentation has defined as the 'referrer' URL for the visitor: