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 requires a Pro or higher subscription.
  • Query arguments contain a key and a value, and come after a question mark in the URL like this: http://domain.com/?key=value
  • A URL can contain multiple sets of query arguments, separated by an ampersand like this: http://domain.com/?key=value&key2=value2&key3=value3
  • The term “query argument” is also sometimes called “query string” or “query parameters”.
  • The query argument rule is case-sensitive.
  • This article covers specific settings in the Display Rules. If you’re just getting started we recommend reading our general Display Rule documentation first.

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. In the campaign builder, navigate to the Display Rules view.
    show display rules
  2. Begin editing your rules and when adding a new rule search for and choose Query Targeting.
    Query Targeting rule in the OptinMonster campaign builder.
  3. Next, 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.
  5. When you’re finished, click Save.

Examples

Here are some examples to help you get started.

E-Commerce

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:

http://www.example.com/checkout/?add-to-cart=532

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:

https://optinmonster.com/?s=content+upgrades

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 →

Troubleshooting

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.