One of the less-known features of Google Tag Manager, a hidden gem if you will, is the URL Source setting in the URL Variable type. It lets you parse any URL String for its components.


The Simmer Newsletter

Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava into your email inbox!

Tip 38: Parse URL strings with the URL Source setting

The setting itself is easy to find. Just edit an existing URL Variable, or create a new one. Then, scroll down to the More Settings divider, expand it, and you’ll see the URL Source drop-down list.

This list will list all the Variables in your container, Built-In Variables included, and you can pick the one you want to parse. Note that the Variable you choose needs to return a properly formatted URL string for parsing to work. A properly formatted URL has at least the protocol (e.g. http:// or https://) and hostname (e.g.

Won’t work:

Will work:

The URL Source setting establishes a URL String that is then parsed according to the Component Type setting you chose. In the image above, I’m using the Referrer Built-In Variable, which returns the referrer URL of the page in question, and I’m parsing it just for its path. In other words, this particular URL Variable will return the path of the previous page.

If the referrer is, the Variable will return /about-simo-ahava/.

Quite a useful feature, and often overlooked.