Search
Clear search
Close search
Google apps
Main menu

Query Parameter targeting

Target specific pages and sets of pages.

Optimize can check query parameters and use them in targeting rules.

In this article:

When to use Query parameter targeting

Query parameters often contain information that you want to use in targeting conditions. For example:

To target users who include user in the experiment when
searched for “nexus” on your site the search query parameter includes a value of “nexus”
were referred by an email campaign the utm_medium parameter has a value of “email”
were referred by the “fall” campaign the utm_campaign parameter has a value of “fall”

 

Query parameter targeting explicitly targets values that occur in the query string of a URL. Query parameters are found between the question mark (?) and hash mark (#), for example:

https://www.example.com/store/landing?utm_campaign=fall#fragment
https://www.example.com/store/search?q=nexus#fragment

Query parameters in the above examples include:

  • Google Analytics campaign parameters (?utm_campaign=fall), and
  • Search queries (?q=nexus).

URLs can contain multiple query parameters, called query components. The first occurs after the question mark (?), and subsequent components occur after the ampersand (&). The following URL includes three query components from the Google Analytics URL builder:

http://www.example.com?utm_source=google&utm_medium=email&utm_campaign=fall

Benefits over URL targeting

Query parameter targeting has the following benefits over URL targeting:

  1. Query parameter rules only look at a portion of the URL between the question mark (?) and hash mark (#).
  2. You can assign human-readable variable names (e.g.: “q” becomes “search”).
  3. You can save, edit and reuse commonly used variables in other experiments.
  4. You can target the unescaped value (e.g.: "a=b") even when the raw URL contains escaped strings (e.g.: "a%3Db”)

Example: Target visitors who searched for a specific product

You want to target an experiment at visitors who search for nexus on your website. Searches generate the following URL structure:

https://www.example.com/store/search?q=nexus

 

To create a rule targeting users searching your website for a specific term, you need to create a custom variable, then build a condition with it.

Step 1: Create a custom variable

  1. Create or edit an experiment.
  2. Click the TARGETING tab.
  3. Click AND to add a new targeting rule.
  4. Click Query Parameter.
  5. Click Variable, then Create new...
    1. Optionally, click an existing variable to edit it.
  6. Enter a Query Key – The query component you wish to target. For example, q.
  7. Name your variable – for example, search query.
  8. Click CREATE VARIABLE.

Optimize query parameter targeting interface.

Step 2: Build a condition with your custom variable

After creating your custom variable, Optimize 360 will populate it in a new targeting condition which you can complete by adding a match type and value. For this example, build the following condition and click SAVE.

Variable Match type Value
search query contains nexus

Optimize query parameter targeting.

This condition will evaluate true if:

  • the value of the first matching query component (unescaped) contains nexus.

This condition will evaluate undefined if:

  • there are no query components containing nexus.

Match types

The following match types are available in query parameter targeting:

Equals / does not equal

Every character in your query parameter, from beginning to end, must be an exact match of the entered value for the condition to evaluate as true. A condition using does not equal will evaluate as true when the query parameter does not equal any of the entered values.

Example:

Variable Match type Value
search query equals nexus

Will evaluate true for:

  • https://www.example.com/store/Search?keywords=nexus
Variable Match type Value
search query does not equal iPhone

Will evaluate true for:

  • https://www.example.com/store/Search?keywords=nexus

Contains / does not contain

The contains match type (also known as a "substring match") allows you to target any occurrence of a substring with a longer string. Contains is useful when targeting a unique query string parameter that appears in multiple URLs.

Example:

Variable Match type Value
page contains 4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=4
Variable Match type Value
page does not contain page=4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=2

Starts with / does not start with

The starts with match type matches identical characters starting from the beginning of the query string up to and including the last character in the string you specify. Use the starts with match type when your query parameters are generally unvarying but can include strings at the end that you want to exclude.

Example:

Variable Match type Value
page starts with 4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=4
Variable Match type Value
page does not start with 4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=2

 

Ends with / doesn't end with

An exact match of the entered value with the end of the URL. You can target shopping cart pages that use /thankyou.html at the end of their URLs.

Example:

Variable Match type Value
page ends with 4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=24
Variable Match type Value
page does not end with 4

Will evaluate true for:

  • http://www.example.com/member.cgi?id=9&page=42

Regex matches / does not regex match

A regular expression uses special characters to enable wildcard and flexible matching. Regex matches are useful when the stem, trailing parameters, or both, can vary in the URLs for the same webpage. If a user could be coming from one of many subdomains, and your URLs use session identifiers, you could use a regular expression to define the constant element of your URL.

Example:

Variable Match type Value
page regex matches checkout.cgi\?page=1

Will evaluate true for:

  • http://sports.example.com/checkout.cgi?page=1&id=123
  • http://fishing.example.com/checkout.cgi?page=1&lang=en&id=123
Variable Match type Value
page does not regex match checkout.cgi\?page=1

Will evaluate true for:

  • http://sports.example.com/checkout.cgi?page=2&id=123

Operators

AND

The AND operator is useful when you wish to target a variation based on multiple rules that all need to be true. Conditions using the AND operator will only evaluate as true when all of the values are met.

Example:

To target users searching for nexus, while browsing from a tablet, create two rules joined by the AND operator.

A query parameter targeting rule:

Variable              Match type Value
search query equals nexus

...and a technology targeting rule:

Variable Match type Value
Device Category equals tablet              

OR

The OR operator is useful for targeting one kind of page with multiple URL configurations. Conditions using the OR operator will evaluate as true when any of the values are met. You can use OR by adding additional values in a URL targeting rule. When targeting URLs, OR is automatically appended to your first URL after pressing return. Simply type additional URLs (followed by return) to continue building conditions with the OR operator.

Example:

To target searches on your website for either nexus or chromecast, create a rule with two site search in the Value field. You'll notice that OR is automatically added after you press enter.

Variable Match type Value
search query equals nexus or... chromecast

 

The OR operator is supported within individual conditions but you can't use it to combine multiple conditions. For example, you can build a condition like this: "path equals /store OR /shop" but you can't use OR across multiple conditions like this: "path equals /store OR host equals example.com"

Was this article helpful?
How can we improve it?