Note that there are some explanatory texts on larger screens.

plurals
  1. POFiring a tag on certain pages in Google Tag Manager
    text
    copied!<p>I am trying to create a regexp to fire a tag within Google Tag Manager on certain pages. </p> <p>The issue I am having is that I do not want to fire this tag on URLs matching a querystring in them, since it is only a session identifier and I do not need the tag to fire on the pages that have a query string. These are basically duplicates and they do not need tracking in a 3rd party tracking program. I know how I could exclude them in GA, but I can't figure out how to do it for the third party tracking. </p> <p>I'll detail the scenario below and what I have tried. </p> <p>Example pages that come up in my URL report if I look in GA: </p> <blockquote> <p>/page </p> <p>/page/subpage?my-handsome-query-string&amp;some-other-data</p> <p>/page/subpage </p> <p>/page/subpage/subsubpage </p> <p>/page/?query-string-again</p> </blockquote> <p>So what I want to do is to fire the tracking on pages that does NOT have the query string, and it is proving quite the issue. </p> <p>If I put in <code>^/page.*[^\?]</code> it just doesn't work. I guess I am completely using the negated character class all wrong? I can't get it working and would require some assistance on how to devise a better regexp. </p> <p>Some other I tried were:</p> <p><code>^/page/.*</code> but this one only matched everything after <code>/page/</code> but not <code>/page</code>.</p> <p>I am not very good with regular expressions, so what I basically want to do is match <code>/page, /page/subpage, /page/subpage/subpage</code> etc, but not any URL that has a query string in it. </p> <p>In GTM I can't create two rules that says <code>"Include {{url path}} matching this" and "Exclude {{url path}} matching \?"</code>, so it all needs to be done within one regexp... And that totally got me at a loss. </p> <p>Edit: Mike gave a good answer to solve my GTM part, but I am still interested in learning if it is possible to do above but with a single regex?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload