{"id":112459,"date":"2023-07-10T11:43:53","date_gmt":"2023-07-10T15:43:53","guid":{"rendered":"https:\/\/optinmonster.com?p=103441&#038;post_type=optinmonster_docs&#038;preview_id=103441"},"modified":"2025-08-08T14:18:05","modified_gmt":"2025-08-08T18:18:05","slug":"how-to-target-campaigns-to-urls-with-query-arguments","status":"publish","type":"optinmonster_docs","link":"https:\/\/optinmonster.com\/docs\/how-to-target-campaigns-to-urls-with-query-arguments\/","title":{"rendered":"How to Target Campaigns to URLs with Query Arguments"},"content":{"rendered":"\n<p>OptinMonster makes it easy to show or hide campaigns to visitors on your site based on the query arguments in the URL.<\/p>\n\n\n\n<p>In this article, you&#8217;ll learn how to target campaigns to URLs with query arguments.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column alert alert-info is-layout-flow wp-block-column-is-layout-flow\">\n<p><strong><em>Before you start<\/em><\/strong>, this feature is available with a <a href=\"https:\/\/optinmonster.com\/pricing\" target=\"_blank\" rel=\"noopener\" title=\"Pro and higher subscription\">Pro and higher subscription<\/a>.<\/p>\n<\/div>\n<\/div>\n\n\n\n<p><b><i>Q<\/i><\/b><em><strong>uery argument is a specific portion of a web page\u2019s URL<\/strong><\/em>, <em>but not the full URL<\/em>. The query argument comes after a question mark and before any anchors.<br><img decoding=\"async\" class=\"alignnone size-full wp-image-172485\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2021\/10\/url-structure.jpg\" alt=\"URL Structure\" width=\"800\" height=\"222\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2021\/10\/url-structure.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2021\/10\/url-structure-300x83.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2021\/10\/url-structure-768x213.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n\n\n\n<p>A URL can contain multiple sets of query arguments, separated by an ampersand like this: <code>http:\/\/domain.com\/?key=value<strong>&amp;<\/strong>key2=value2<strong>&amp;<\/strong>key3=value3<\/code><\/p>\n\n\n\n<p>The term &#8220;query argument&#8221; is also sometimes called &#8220;query string&#8221; or &#8220;query parameters&#8221;.<\/p>\n\n\n\n<p>The query argument rule is case-sensitive.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Query Argument Targeting<\/h2>\n\n\n\n<p>When you&nbsp;<a href=\"https:\/\/optinmonster.com\/docs\/creating-your-first-optin\/\" target=\"_blank\" rel=\"noopener\" title=\"\">create a campaign<\/a> in OptinMonster you can target URLs on your site that contain certain query arguments.<\/p>\n\n\n\n<p>To show or hide your campaign on URLs with query arguments, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to the <strong>Display Rules<\/strong> view in the campaign builder.<br><img decoding=\"async\" width=\"800\" height=\"560\" class=\"alignnone size-full wp-image-180093\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/06\/display-rules-view.jpg\" alt=\"Navigate to the Display Rules in the OptinMonster campaign builder.\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/06\/display-rules-view.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/06\/display-rules-view-300x210.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/06\/display-rules-view-768x538.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/li>\n\n\n\n<li>Next, when adding or editing a rule select <strong>Where (Targeting)<\/strong> from the left-hand list and select the <strong>Query Targeting<\/strong> option.<br><img decoding=\"async\" width=\"800\" height=\"545\" class=\"alignnone size-full wp-image-180365\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-rule.jpg\" alt=\"Query Targeting rule in OptinMonster.\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-rule.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-rule-300x204.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-rule-768x523.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/li>\n\n\n\n<li>Finally, enter the name of the key and value, if you&#8217;re doing any type of matching, into the provided fields.<br><img decoding=\"async\" width=\"800\" height=\"163\" class=\"alignnone size-full wp-image-180364\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-options.jpg\" alt=\"Query Argument Targeting options.\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-options.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-options-300x61.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-options-768x156.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><br>You&#8217;ll have the following match options available:\n<ul class=\"wp-block-list\">\n<li><strong>Key only:<\/strong>\n<ul class=\"wp-block-list\">\n<li>exists<\/li>\n\n\n\n<li>does not exist<\/li>\n\n\n\n<li>is empty (no query args)<\/li>\n\n\n\n<li>is not empty (has query args)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Value only:<\/strong>\n<ul class=\"wp-block-list\">\n<li>empty<\/li>\n\n\n\n<li>not empty<\/li>\n\n\n\n<li>is empty<\/li>\n\n\n\n<li>is not empty<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Key and Value:<\/strong>\n<ul class=\"wp-block-list\">\n<li>exactly matches<\/li>\n\n\n\n<li>does not exactly match<\/li>\n\n\n\n<li>contains<\/li>\n\n\n\n<li>does not contain<\/li>\n\n\n\n<li>starts with<\/li>\n\n\n\n<li>does not start with<\/li>\n\n\n\n<li>ends with<\/li>\n\n\n\n<li>does not end with<\/li>\n\n\n\n<li>is anything<\/li>\n\n\n\n<li>matches the pattern<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>When you&#8217;re finished, <strong>Save<\/strong> the campaign.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Examples<\/h2>\n\n\n\n<p>Here are some examples to help you get started.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Marketing Campaign<\/h3>\n\n\n\n<p>If you run a marketing campaign like Google Adwords or an Email Campaign, each URL will contain UTM Parameters you can target. <a href=\"https:\/\/optinmonster.com\/docs\/how-to-target-optins-to-your-pay-per-click-campaigns\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Our guide here shows how you can target campaigns to your pay-per-click marketing campaigns<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ecommerce\">E-Commerce<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Let&#8217;s assume your e-commerce site uses a query argument structure like the following to add a product to the shopping cart:<\/p>\n\n\n\n<p><code><\/code><code>http:\/\/www.example.com\/checkout\/?add-to-cart=532<\/code><\/p>\n\n\n\n<p>The URL has one query argument key and one query argument value:<\/p>\n\n\n\n<p><strong>Key:<\/strong> add-to-cart<br><strong>Value:<\/strong> 532<\/p>\n\n\n\n<p>When the above URL is visited on our example e-commerce store, the product with ID 532 is automatically added to the visitor&#8217;s shopping cart.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>To do this, we&#8217;ll add a query arg rule to the Display Rules and enter the key and value with <strong>exactly matches<\/strong> condition.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"800\" height=\"164\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-cart-example.jpg\" alt=\"Add to cart example using Query Argument Targeting in OptinMonster.\" class=\"wp-image-180363\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-cart-example.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-cart-example-300x62.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-cart-example-768x157.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Site Search<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>For most websites, the query string for searches will look similar to the following:<\/p>\n\n\n\n<p><code>https:\/\/optinmonster.com\/?s=content+upgrades<\/code><\/p>\n\n\n\n<p>For the URL above, there is one query argument key and one query argument value.<\/p>\n\n\n\n<p><strong>Key:<\/strong> s<br><strong>Value:<\/strong> content+upgrades<\/p>\n\n\n\n<p><em>*The plus (+) sign typically represents a space between search terms since a URL cannot contain spaces.<\/em><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>To do this, we&#8217;ll add a query arg rule to the Display Rules and enter the key and value with <strong>exactly matches<\/strong> condition.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"800\" height=\"169\" src=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-search-example.jpg\" alt=\"Search example using Query Argument Targeting in OptinMonster.\" class=\"wp-image-180362\" srcset=\"https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-search-example.jpg 800w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-search-example-300x63.jpg 300w, https:\/\/optinmonster.com\/wp-content\/uploads\/2023\/04\/query-arg-search-example-768x162.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">Is this rule case-sensitive?<\/h5>\n\n\n\n<p>Yes, all operator conditions for the query argument rule are case-sensitive.<\/p>\n\n\n\n<p>For example, the query argument key of &#8216;Hello&#8217; is not the same as &#8216;hello&#8217;.<\/p>\n\n\n\n<p>Be sure to check the case of your query arguments to be sure the Display Rule configured matches.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;ll learn how to target campaigns to URLs with query arguments. Query argument is a specific portion of a web page\u2019s URL, but not the full URL. The query argument&nbsp;&hellip;<\/p>\n","protected":false},"author":4657,"comment_status":"open","ping_status":"closed","template":"","documentation\/categories":[28201],"documentation\/tags":[31399,31498,31415,31431,31856,31411,31455],"class_list":["post-112459","optinmonster_docs","type-optinmonster_docs","status-publish","hentry","categories-display-rules"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/112459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/types\/optinmonster_docs"}],"author":[{"embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/users\/4657"}],"replies":[{"embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/comments?post=112459"}],"version-history":[{"count":22,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/112459\/revisions"}],"predecessor-version":[{"id":197988,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/112459\/revisions\/197988"}],"wp:attachment":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/media?parent=112459"}],"wp:term":[{"taxonomy":"categories","embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/categories?post=112459"},{"taxonomy":"internal_tags","embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/tags?post=112459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}