How to Target Campaigns to URLs with Query Arguments

OptinMonster makes it easy to show or hide campaigns to visitors on your site based on the query arguments in the URL.

In this article, you’ll learn how to target campaigns to URLs with query arguments.

Before You Start

Here are some things to know before you begin:

  • Query argument targeting is available with a Pro or higher subscription.
  • Query arguments contain a key and a value, and come after a question mark in the URL like this:
  • When you see Query argument mentioned in this article, the query argument is a specific portion of a web page’s URL, but not the full URL. The query argument is the text after a question mark and before any anchors.
    URL Structure
  • A URL can contain multiple sets of query arguments, separated by an ampersand like this:
  • The term “query argument” is also sometimes called “query string” or “query parameters”.
  • The query argument rule is case-sensitive.
  • Learn more about our Display Rules,

Query Argument Targeting

When you create a campaign in OptinMonster you can target URLs on your site that contain certain query arguments.

To show or hide your campaign on URLs with query arguments, follow these steps:

  1. Navigate to the Display Rules view in the campaign builder.
    Display Rules view in the OptinMonster campaign builder
  2. When adding a new rule, select Query Targeting from the Targeting menu.
    Select Query Argument Targeting Display Rule.
  3. You’ll have the following match options available:
    • Key only:
      • exists
      • does not exist
      • is empty (no query args)
      • is not empty (has query args)
    • Value only:
      • empty
      • not empty
      • is empty
      • is not empty
    • Key and Value:
      • exactly matches
      • does not exactly match
      • contains
      • does not contain
      • starts with
      • does not start with
      • ends with
      • does not end with
      • is anything
      • matches the pattern
  4. Finally, enter the name of the key and value, if you’re doing any type of matching, into the provided fields.
    Query Argument Targeting configuration options
  5. When you’re finished, click Save.


Here are some examples to help you get started.

Marketing Campaign

If you run a marketing campaign like Google Adwords or an Email Campaign, each URL will contain UTM Parameters you can target. Our guide here shows how you can target campaigns to your pay-per-click marketing campaigns.


If your e-commerce platform uses query arguments in the URL to add products to the shopping cart you could show a specific campaign when a visitor adds a specific product to their cart.

Let’s assume your e-commerce site uses a query argument structure like the following to add a product to the shopping cart:

The URL has one query argument key and one query argument value:

Key: add-to-cart
Value: 532

When the above URL is visited on our example e-commerce store, the product with ID 532 is automatically added to the visitor’s shopping cart.

Now, we can target a campaign to show only when a URL with that query argument is visited. Perhaps we want to offer a specific upsell in the campaign when the product with ID 532 is added to the cart.

To do this, we’ll add a query arg rule to the Display Rules and enter the key and value with exactly matches condition.

Ecommerce Query Arg

Site Search

Some websites will use query arguments in the URL to generate search results. If your website follows this convention you can use query argument targeting to show a specific campaign to visitors who search for a certain term.

For most websites, the query string for searches will look similar to the following:

For the URL above, there is one query argument key and one query argument value.

Key: s
Value: content+upgrades

*The plus (+) sign typically represents a space between search terms since a URL cannot contain spaces.

Now, we can target a campaign to show only when a URL with that query argument is visited. This may be a good opportunity to show a campaign that offers a free ebook related to content upgrades.

To do this, we’ll add a query arg rule to the Display Rules and enter the key and value with exactly matches condition.

Search Query Arg

If you’re serious about jumpstarting your website business growth, then get started with OptinMonster today!

Get Started With OptinMonster Today!

BONUS: Done-For-You Campaign Setup ($297 value)
Our conversion experts will design 1 free campaign for you to get maximum results – absolutely FREE! Click here to get started →


Is this rule case-sensitive?

Yes, all operator conditions for the query argument rule are case-sensitive.

For example, the query argument key of ‘Hello’ is not the same as ‘hello’.

Be sure to check the case of your query arguments to be sure the Display Rule configured matches.