{"id":627,"date":"2021-10-04T19:32:56","date_gmt":"2021-10-04T18:32:56","guid":{"rendered":"https:\/\/organicdigital.co\/blog\/?p=627"},"modified":"2025-11-25T13:29:43","modified_gmt":"2025-11-25T13:29:43","slug":"how-to-easily-configure-multiple-urls-parameters-in-one-trigger-using-google-tag-manager","status":"publish","type":"post","link":"https:\/\/daveashworth.co\/blog\/how-to-easily-configure-multiple-urls-parameters-in-one-trigger-using-google-tag-manager\/","title":{"rendered":"How To: Easily Configure Multiple URLs &#038; Parameters In One Trigger Using Google Tag Manager"},"content":{"rendered":"\n<p>As a <a href=\"https:\/\/daveashworth.co\/skills\/google-tag-manager-consultant\/\">Google Tag Manager consultant<\/a>, I am often looking for innovative ways to use it to perform on site SEO. One of the main things I use it it for is to de-index unwanted content such as taxonomy, paginated and parameterised content (<a href=\"https:\/\/daveashworth.co\/blog\/how-to-implement-robots-noindex-tag-with-google-tag-manager\/\">I wrote a blog post on how to add a noindex tag via GTM here<\/a>).&nbsp;&nbsp;<\/p>\n\n\n\n<p>More often than not when first <a href=\"https:\/\/daveashworth.co\/services-and-consultancy\/website-seo-audits-consultant\/\">auditing a site<\/a>, you will come across lots of unwanted low quality indexed content such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/category_page?mode=grid3<\/li>\n\n\n\n<li>\/category_page?limit=16&amp;mode=grid3<\/li>\n\n\n\n<li>\/category_page?dir=desc&amp;limit=all&amp;order=position<\/li>\n\n\n\n<li>\/category_page?dir=asc&amp;order=name<\/li>\n\n\n\n<li>\/category_page?p=3<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>along with other page types, such as:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/catalog\/product\/view\/id\/24838<\/li>\n\n\n\n<li>\/catalog\/product\/view\/id\/27703<\/li>\n\n\n\n<li>\/productalert\/add\/stock\/product_id\/11221\/<\/li>\n\n\n\n<li>\/productalert\/add\/stock\/product_id\/22112\/<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>And so on.<\/p>\n\n\n\n<p>Basically, <a href=\"https:\/\/daveashworth.co\/skills\/ecommerce-seo-consultant\/magento\/\">Magento<\/a>, I\u2019m looking at you \u2013 but the above is common on most ecommerce sites where filters are involved, or <a href=\"https:\/\/daveashworth.co\/skills\/wordpress-seo-consultant\/\">WordPress<\/a> where taxonomy pages are rife (but easily de-indexable <a href=\"https:\/\/yoast.com\/\" target=\"_blank\" rel=\"noopener\">via Yoast<\/a>)<\/p>\n\n\n\n<p>Until recently, I would manage these by creating a trigger for each indivudal URL structure and parameter, as I basically didn\u2019t know any better.&nbsp;&nbsp; This approach is perfectly acceptable, so long as the number of variations of triggers is low:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"913\" height=\"225\" src=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/triggers.jpg\" alt=\"Triggers\" class=\"wp-image-628\" srcset=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/triggers.jpg 913w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/triggers-300x74.jpg 300w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/triggers-150x37.jpg 150w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/triggers-768x189.jpg 768w\" sizes=\"(max-width: 913px) 100vw, 913px\" \/><\/figure>\n\n\n\n<p>But if the number of parameters is high, you need another approach as it basically takes time to do this.&nbsp;&nbsp; And there\u2019s always got to be a way to save time.<\/p>\n\n\n\n<p>And there are ways to save time.&nbsp;&nbsp;<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/daveashworth.co\/blog\/how-to-easily-configure-multiple-urls-parameters-in-one-trigger-using-google-tag-manager\/#Regex\" >Regex<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/daveashworth.co\/blog\/how-to-easily-configure-multiple-urls-parameters-in-one-trigger-using-google-tag-manager\/#Custom_JavaScript_Variable\" >Custom JavaScript Variable<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Regex\"><\/span>Regex<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>I\u2019ll be honest, I hate Regex.&nbsp; I\u2019ve been in the coding game to varying degrees for over 20 years and bar the pipe symbol, aka OR which looks like |, I can never get them to work.&nbsp;&nbsp; So, if I can avoid them, I will.<\/p>\n\n\n\n<p>But the pipe symbol is one option here, to a degree, so far as my limited knowledge goes anyway.<\/p>\n\n\n\n<p>If you want to block URL structures based on folders, you could go with a tag such as the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"882\" height=\"86\" src=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-29-55.jpg\" alt=\"regex\n\" class=\"wp-image-629\" srcset=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-29-55.jpg 882w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-29-55-300x29.jpg 300w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-29-55-150x15.jpg 150w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-29-55-768x75.jpg 768w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><\/figure>\n\n\n\n<p>So, on my site, that would fire on:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/daveashworth.co\/services-and-consultancy\/\">https:\/\/daveashworth.co\/services-and-consultancy\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/daveashworth.co\/services-and-consultancy\/website-migrations-consultant\/\">https:\/\/daveashworth.co\/services-and-consultancy\/website-migrations-consultant\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/daveashworth.co\/support\/in-house\/\">https:\/\/daveashworth.co\/support\/in-house\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/daveashworth.co\/about\/testimonials\/\">https:\/\/daveashworth.co\/about\/testimonials\/<\/a><\/li>\n<\/ul>\n\n\n\n<p>Where it starts to get messy, is when you want to fire URL parameters via the = symbol (it might be easy, but as I say, I hate regex and am not willing to take this any further).<\/p>\n\n\n\n<p>The other drawback is that if you have many permutations you wish to block, managing them all in one input box gets a bit fiddly. The following solution therefore is FAR better:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Custom_JavaScript_Variable\"><\/span>Custom JavaScript Variable<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This a much more elegant approach, as you can use a bespoke JavaScript function to set up an array of URL structures and parameters to check for \u2013 if one of them is present in the current URL, the variable returns true, if not, it returns false.<\/p>\n\n\n\n<p>You would set up a Custom JavaScript Variable as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"771\" height=\"739\" src=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-37-54.jpg\" alt=\"Custom JavaScript Variable\n\" class=\"wp-image-630\" srcset=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-37-54.jpg 771w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-37-54-300x288.jpg 300w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-37-54-150x144.jpg 150w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-37-54-768x736.jpg 768w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><\/figure>\n\n\n\n<p>The full code is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function() \n{\n\tvar deIndexTheseURLs = \n\t&#91;\n\t\t'\/catalog\/',\n\t\t'\/catalogsearch\/',\n\t\t'\/customer\/',\n\t\t'cjdata=',\n\t\t'colour_shade=',\n\t\t'dir=',\n\t\t'extension_length=',\n\t\t'extension_style=',\n\t\t'extension_weight=',\n\t\t'gclid=',\n\t\t'hair_extension_colour=',\n\t\t'limit=',\n\t\t'mode=',\n\t\t'options=',\n\t\t'order=',\n\t\t'p=',\n\t\t'platform=',\n\t\t'product_list_order=',\n\t\t'store=',\n\t\t'wig_length=',\n\t\t'q='\n\t];\n\n\tfor (var i = 0; i &lt; deIndexTheseURLs.length; i += 1) \n\t{  \n\t\tif (document.location.href.indexOf(deIndexTheseURLs&#91;i]) &gt; -1) \n\t\t{\n\t\t\treturn true;\n\t\t}\n\t};\n\nreturn false;\n}<\/code><\/pre>\n\n\n\n<p>Here, the list of structures is easy enough to manage and edit at any time.<\/p>\n\n\n\n<p>The array contains various structure formats, which is then looped through and checks against the current URL to see if the URL structure is a substring.<\/p>\n\n\n\n<p>If it is, it returns true, if not false.<\/p>\n\n\n\n<p>You then set up a trigger to fire when the variable returns true, and associate this with your no index tag as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"766\" height=\"477\" src=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-43-01.jpg\" alt=\"Custom Javascript Variable Trigger\" class=\"wp-image-631\" srcset=\"https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-43-01.jpg 766w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-43-01-300x187.jpg 300w, https:\/\/daveashworth.co\/blog\/wp-content\/uploads\/2021\/10\/2021-10-04_17-43-01-150x93.jpg 150w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/figure>\n\n\n\n<p>And that\u2019s it. Easy.&nbsp; If you have any questions, queries or need any assistance getting this set up, feel free to get in touch, am always happy to help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find out how to easily configure multiple URL structures and parameters via GTM with one easy to manage trigger<\/p>\n","protected":false},"author":1,"featured_media":632,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4],"tags":[],"class_list":["post-627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tag-manager","category-crawl-rate"],"_links":{"self":[{"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/posts\/627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/comments?post=627"}],"version-history":[{"count":2,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":1825,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/posts\/627\/revisions\/1825"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/media\/632"}],"wp:attachment":[{"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/media?parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/categories?post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daveashworth.co\/blog\/wp-json\/wp\/v2\/tags?post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}