Cloud Confusing

Explaining hosting, AWS, Wordpress, static sites, and all manner of cloud solutions.

Google’s Tag Manager is a super useful tool, but, just like with Google Analytics and Ad Manager, it works best with types of things, not a set of specific things. For example, GA is great at finding the pageview count for every article that has custom dimension 2 = “true” but it’s not good at given the pageview count for a group of 10 random URLs are want to investigate.

This is particularly annoying when you are setting up very granular GTM triggers, but there is a simple work around. The same logic works in Google Analytics.

GTM Tag on an Arbitrary List of Pages

If you want GTM to fire a given tag on a list of multiple unique pages there is simple, not particularly scalable fix for you.

Assuming your tag is already built and saved, add a new trigger. Choose your trigger type, say a pageview or event, just to keep things simple.

Now pick the radio button for “Some Page Views” or “Some Events” which is where you can filter the applicable pages down.

Next, pick “Page URL” as the filtering mechanism. You can use page path as well, but know that it’ll exclude anything before the “/” in https://www.example.com/Directory/Structure.

Next, pick “matches RegEx” as your selection type, you might be tempted to pick “contains” but don’t do it, that’s too exact of a match.

Now is the fun part: pick out the unique strings from your URLs, or the whole paths, and put them in a last box, where the URL is identified. Use a pipe (|) to separate them and parentheses on both ends. So you might have something like:

(url1|url2|url3|url4)

While you don’t need the full URLs, just a unique string or identified from each URL is fine, you can imagine that this will get quite long. That’s why this method is not very scalable, and ultimately it’ll be better to do this with an identifier like a specific directory in your URL, a custom dimension, UTM parameter or something that can work across more pages, but this will work in a pinch and be good for a few pages.

Google Analytics Tracking on an Arbitrary List of Pages

The above works for Google Analytics as well, but you’ll need a space where you can manually enter in a URL in order to perform your search. This means a search box, which you can find in Advanced Search of Behavior > Site Content > All Pages or through Custom Reports.

Both of these are search boxes that will accept regex commands like | for “or” even without explicitly stating it as being a regex request in the case of the Advanced Search.

With Custom Reports you’ll just want to enter a filter that has a pipe and then your identifying string in the search box, like in the above image. Make sure to “Include” the attribute you want to filter on (in this case Page) and choose Regex.

This is a Stopgap

Let’s not lose sight of the fact that this method, while useful, is a stopgap measure. This system won’t work past five (or so) pages because the string will get too long and too messy. Also at some point the strings are very difficult to read through so you, as a human, become a point of failure. And let’s not forget that there are character limits on these fields (thought the filter on Custom Reports will take thousands of characters).

The best solution, as mentioned above, will be to add a better descriptor or attribute to the pages that you want to group than the URL. This could be a custom dimension, content group, or any of a huge number of attributes.

May 20th, 2020

Posted In: Analytics

Tags: , ,


© Cloudconfusing.com 2022 | Privacy Policy | About | UTM Creator | CVE Reporting