URL 2.0 - Custom Variable Template
The URL 2.0 template is designed to partially or completely replace the built-in URL variable in Google Tag Manager.
You can use it to build a custom URL string. With this option, you select the parts of the URL to combine into a new string.
For example, if the user is on
https://www.mydomain.com/my-path/?login=true#customClient, and you select Hostname, Path and Fragment from the variable settings, the end result would be:
In Advanced Settings, you can choose whether to parse the Page URL or the Referrer URL. Unfortunately, you can't use a Google Tag Manager variable to produce the URL string, because the template APIs do not support parsing custom URLs into the type of object required by the template.
From Variable type you can also choose to retrieve a value for a Query key or a Fragment key.
The first looks through the query string (
?key=value&key2=value2) for the given key, and returns the value of the first match as a string, or all matches as an array (if the query key is incorrectly added multiple times).
The second looks through the fragment (
#somekey=value) for the given key, and returns its value.
|12 December 2019||Fix fragment key handling to parse question marks as well.|
|16 September 2019||Initial release.|