How to Target Campaigns to URLs with Query Arguments

OptinMonster can present targeted offers to readers based on the query parameters present in the page’s URL. Additionally, you can use the URL Parameter rule to retarget visitors for additional marketing or upselling.

REQUIREMENT: You’ll need at least Pro subscription to use the URL Parameter targeting rule. If you don’t already have a Pro subscription, upgrade your subscription first, then come back and follow along to learn how you can target users based on their URL Parameters.
WARNING: Not all website follow the same URL structure shown in the example below. For example, some sites will display search results as http://example.com/?q=my+search+term or without a query string at all. Please examine your own website to find the URL structure to use in your display rules.

What is a Query Argument?

A query argument (also called a query string) is a small snippet of code added to your URL which further processes the url being viewed.

A query argument has two parts: the query argument key, and the query argument value.

The structure of a URL with a query argument looks like this:

http://domain.com/?key=value

The “URL query arg” display rule allows you to target these keys and values when choosing where and when your campaigns should display.

Query Arg Rule

You have the following conditions available when targeting Query Arguments:

  • 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

These conditions allow you very fine control over what campaigns are displayed in response to your specific query arguments.


Examples of How to Use the Query Argument Rule

E-Commerce
WARNING: Not all e-commerce sites follow the same URL structure shown in the example below. For example, some sites will use http://example.com/checkout/cart/add?product=2880&qty=2 to add a product directly to a cart. Please examine your own e-commerce platform to find the URL structure to use in your display rules.

The URL below adds the product with the ID 532 to the shopping cart of an e-commerce website. When visited, the product will be automatically added to the cart, and the user will be able to proceed to checkout.

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

Perhaps you’d like to show a campaign with an upsell specific to the product ID 532 once someone adds that product to their cart. You can do that using the Display Rule, configured as shown below:

Ecommerce Query Arg

WARNING: Not all website follow the same URL structure shown in the example below. For example, some sites will display search results as http://example.com/?q=my+search+term or without a query string at all. Please examine your own website to find the URL structure to use in your display rules.

Offer targeted campaigns to readers searching for specific content on your site using the Query Parameters rule. For most websites, the query string for searches looks like something like this:

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

In this example, the reader searched for “content upgrades” at https://optinmonster.com and was shown a list of every article or page on the site containing the words “content upgrades.” This would be a great opportunity to share an offer for an ebook related to content upgrades.

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

Key: s Value: content+upgrades

Search Query Arg

Post Types
WARNING: Not all website follow the same URL structure shown in the example below. For example, some sites will display custom content types as http://example.com/tours. Please examine your own website to find the URL structure to use in your display rules.

If your site offers multiple post types, you can target campaigns to display only when those post types are being viewed.

In this example, we’ll see how you can use the conditions of the Query Parameter rule to further refine where a campaign displays.

http://example.com/?post_type=tours

The URL above will display only posts of the post_type “tours.” It has one query argument key and one query argument value.

Key: post_type Value: tours

Post Type Query Arg

NOTE: If you have any questions about how you might use our Query Parameter Display Rule for onsite retargeting, please feel free to send us a support ticket. We’re always happy to help!

Wondering how you can target your users even further? You can target a user’s web browser’s cookies for precision marketing.


Frequently Asked Questions

Q: How do I use the Matching the Pattern Rule?

A: You can learn more about our Matching the Pattern rule, which uses RegEx (Regular Expressions) by reading our Matching the Pattern guide.


Q: How do I show the campaign when a query argument value does not match?

A: Since the query argument key condition is required, this is going to require two rules configured as OR conditions to show the campaign to users who do not have that value. Let’s assume we want the campaign to show only when the query argument value for utm_medium does not equal ‘some_medium’.

http://example.com/?utm_medium=some_medium

The first rule should have the following condition:

Show when “query argument key does not match ‘utm_medium’ and query argument value ‘is anything'”.

Not Match Key Target

This will show to all users who do not have that key at all.

The second rules should have the following conditions:

Show when “query argument key exactly matches ‘utm_medium’ and query argument value does not match ‘some_medium'”

Not Match Value Target

This will show to users who have the key, but with a different value.