Page Path vs Page URL in GTM: Which Variable Should You Actually Use?

page path vs page url in GTM
Page Path vs Page URL in GTM | Which One Should You Use?

At some point while building triggers or variables in Google Tag Manager, you'll hit a very specific wall: GTM offers you Page Path and Page URL as built-in variables, and they look similar enough that picking between them feels like a coin flip. But it's not. Choosing the wrong one for the wrong situation is one of the most common reasons GTM triggers fire when they shouldn't — or don't fire when they should.

The difference between the two comes down to how much of the URL each variable actually returns. Page Path gives you a clean, stripped-down slice. Page URL gives you the full picture including parts that can vary unpredictably. Knowing which to reach for — and when — will make your triggers more reliable and your tracking far more consistent.

In this guide, we'll cover exactly what each variable returns, show you a real URL broken into its components, walk through GTM's custom URL variable options, and give you a clear decision framework for choosing between them.

🏷️

Is your GTM setup built on the right variables and triggers? Incisive Ranking can audit your container and fix the gaps before they cause data problems.

Get a Free GTM Audit

Understanding the Anatomy of a URL First

Before comparing the two variables, it helps to see a URL broken into its individual parts — because Page Path and Page URL each return a different slice of it. Take this example URL:

https://www.example.com/shop/trainers/?colour=black&size=10#reviews
Protocol: https:// Hostname: www.example.com Path: /shop/trainers/ Query: ?colour=black&size=10 Fragment: #reviews
Protocol
Hostname
Page Path
Query String
Fragment (#)

Every URL you encounter in GTM can be broken down into these five components. The key question is: which of those components do you actually need for your trigger or variable to work correctly? That's what determines whether you should use Page Path or Page URL.

What Does the Page Path Variable Return?

The Page Path built-in variable in GTM returns only the path portion of the current page's URL — everything that comes after the hostname, but stopping before any query string (?), fragment (#), or port number (:).

Using the example URL above, Page Path would return:

/shop/trainers/

That's it. No protocol, no domain, no ?colour=black, no #reviews. Just the clean path that identifies which page the user is on.

This trimmed-down output is intentional — and it's actually what makes Page Path so useful for building triggers. When you write a trigger that says "fire on any page containing /shop/", you want it to fire reliably regardless of what query parameters happen to be in the URL at that moment. Page Path ensures those extras don't interfere.

Always starts with a forward slash. Page Path will always begin with / — for example, /contact/ or /blog/seo-tips/. If you're building a trigger condition and your value doesn't start with /, it won't match.
Diagram comparing Page Path vs Page URL in Google Tag Manager showing what each variable returns from a URL

A visual breakdown of what Page Path and Page URL each return from the same URL — the difference in scope is clear

What Does the Page URL Variable Return?

The Page URL built-in variable returns the full address of the current page — including the protocol, hostname, page path, query string, and port number. The only thing it excludes is the fragment (# anchor).

Using the same example, Page URL would return:

https://www.example.com/shop/trainers/?colour=black&size=10

Notice that the #reviews fragment is excluded — that's standard browser behaviour; fragments are client-side only and don't get sent in HTTP requests, so GTM strips them from Page URL too.

Because Page URL includes the query string, it's the right variable whenever you need to read or match against UTM parameters, GCLID values, or any other URL parameters that carry important context about the session.

VariableExample Return ValueIncludes Query Params?Includes Fragment (#)?
Page Path/shop/trainers/❌ No❌ No
Page URLhttps://www.example.com/shop/trainers/?colour=black&size=10✅ Yes❌ No
⚠️ Common trigger mistake: If you build a trigger using Page URL and set the condition to "equals" a specific URL — like https://example.com/thank-you/ — it will fail to fire for users who arrived via a campaign link, because their URL will include UTM parameters like ?utm_source=google. Use Page Path with "equals" conditions for reliable page-specific triggers.
⚙️

Triggers firing inconsistently or missing conversions? Our team at Incisive Ranking can diagnose and fix your GTM trigger setup.

Talk to Our Team

Beyond the Basics: GTM's Custom URL Variable

The built-in Page Path and Page URL variables cover most common use cases, but there are plenty of situations where you need something more specific — just the hostname, just a single query parameter value, or just the fragment. That's where GTM's URL Variable (a user-defined variable type) comes in.

To create one, go to Variables → New → URL in your GTM container. You'll then choose which component of the URL the variable should return.

URL variable configuration screen in Google Tag Manager showing component type options

GTM's URL Variable lets you extract any individual component from a page URL — far more flexible than the built-in Page Path or Page URL alone

Here's a breakdown of every component type the URL Variable supports, using this example URL:

https://www.example.com/welcome:8080?gclid=aabbcc123#home
Full URL
https://www.example.com/welcome?gclid=aabbcc123

Returns the complete URL excluding the hash fragment. Similar to Page URL.

Protocol
https

Returns just the protocol. Useful for detecting HTTP vs HTTPS pages — handy for security audits.

Host Name
www.example.com

Returns the domain without the port. You can optionally strip www. to normalise the output.

Port
8080

Returns the port number from the URL. Returns 80 (HTTP) or 443 (HTTPS) when no port is specified.

Path
/welcome/

Returns the pathname only — identical in output to the built-in Page Path variable.

Query
aabbcc123 (for key: gclid)

Returns the value of a specific query parameter. Specify the key name (e.g. gclid) and it returns just that value. Returns undefined if the key isn't present.

Fragment
home

Returns the value after the # symbol. Neither Page Path nor Page URL captures this — the custom URL Variable is the only way to access it.

Real-world use case for Query component: If you want to capture which UTM source brought a user to the site and send it as a GA4 event parameter, create a custom URL Variable with component type "Query" and key name utm_source. The variable will return the value (e.g. google or newsletter) which you can then pass directly into your GA4 tag as an event parameter.

One More Setting Worth Knowing: Source Selector

By default, the URL Variable reads from the current page address. But you can change the source in the More Settings panel — for example, setting it to read from Click URL instead. This lets you extract query parameters or hostnames from links that users are clicking on, not just the page they're currently viewing. Useful for tracking outbound link destinations or campaign-tagged CTAs.

Page Path vs Page URL: When to Use Which

The right choice comes down to what your trigger or variable actually needs to know. Here's the practical decision guide:

✅ Use Page Path when...

  • Building trigger conditions based on which page loaded (e.g. /thank-you/)
  • You want triggers that work regardless of what query parameters are in the URL
  • Setting up pageview-based triggers for specific sections of the site (e.g. all pages under /blog/)
  • Passing the current page location as a GA4 event parameter without cluttering it with query noise
  • Writing regex-based trigger conditions — Page Path is cleaner and more predictable

✅ Use Page URL when...

  • You need to capture or match against UTM parameters (utm_source, utm_campaign, etc.)
  • Tracking GCLID or FBCLID parameters for ad conversion data
  • Debugging — when you need the full address to understand exactly which version of a link was loaded
  • Building a trigger that should only fire for a specific campaign-tagged URL
  • Reading affiliate or referral tracking parameters from the URL

A Practical Example That Makes It Click

You want to fire a GA4 conversion tag every time someone reaches your order confirmation page at /order-complete/. You set up a Page View trigger with the condition: Page Path — contains — /order-complete/. This fires for every visitor who reaches that page, regardless of whether their URL looks like /order-complete/ or /order-complete/?order_id=98765&utm_source=email. The trigger works every time.

Now imagine you'd built that same trigger with Page URL using an "equals" condition. The moment a visitor arrived from an email campaign, their URL would include UTM parameters — and the trigger would never match. That's silent data loss: the tag doesn't fire, the conversion doesn't get recorded, and you have no idea why.

General rule of thumb: Default to Page Path for trigger conditions whenever you're matching against a specific page or section. Only switch to Page URL when you explicitly need the query string to be part of the match — or when you're reading URL parameters for passing into tags.

Quick Reference: All GTM Page Variables at a Glance

VariableReturnsExample OutputBest For
Page PathPath only (after hostname, before query)/shop/trainers/Trigger conditions, page identification
Page URLProtocol + hostname + path + query stringhttps://example.com/shop/?colour=blackReading UTM/GCLID params, full URL matching
Page HostnameDomain name onlywww.example.comMulti-domain containers, subdomain filtering
URL Variable (Query)Value of a specific query parametergoogle (for utm_source=google)Sending UTM values as GA4 event parameters
URL Variable (Fragment)Value after the # symbolreviews (from #reviews)Tracking anchor-based navigation on long pages
URL Variable (Protocol)http or httpshttpsSecurity auditing, mixed-content detection

Wrapping Up: The Right Variable Makes Your Tracking Reliable

Page Path and Page URL are both available in every GTM container by default — but they're not interchangeable. Page Path is your go-to for trigger conditions because it strips away the unpredictable parts of a URL (query strings, fragments) and just tells you which page the user is on. Page URL is your go-to when the query string itself is the point — reading campaign parameters, capturing tracking IDs, or debugging exactly which URL variant fired a tag.

When neither covers your needs precisely enough, GTM's custom URL Variable fills the gaps — letting you extract any individual component of a URL with surgical precision, including query parameter values and hash fragments that the built-in variables don't expose.

Getting this right from the start means your triggers fire consistently, your data is clean, and you're not chasing ghost discrepancies between what you expected to track and what GA4 actually recorded. At Incisive Ranking, we help businesses build GTM setups that work correctly the first time — and stay working as the site evolves.

Want to make sure your GTM variables and triggers are built the right way? Get a free audit from the Incisive Ranking team today.

Get My Free GTM Audit View Our Services

Follow Us:

About Us

We are experts in Tags and Tracking Services. With experience in eCommerce and Custom Conversion tracking, Server Side Tagging, and Data tracking to help you get the advantage of ACCURATE data for better decision making. With more than 6 years of experience, We have already delivered more than 500 projects.