GTM Variable “Click URL Host Name”
Variable “Click URL Host Name”
Google Tag Manager allows you to easily track the full destination path (URL) of all link clicks. Quite often you will need the ability to group link clicks by host name (domain) rather by the full URL path.
Before you can use the host name/domain as a selection criteria you need to create a new “User-Defined Variable” (with variable type “Auto-Event Variable”) that extracts the host name from the built-in “Click URL” variable.
How to create a custom variable in Google Tag Manager
- Click on “Variables” (in the left menu)
- Scroll down to “User-Defined Variables” and click “New”
- Fill in the below data
- Click on “Create Variable”
Done! A new variable named “Click URL Host Name” is now available.
If the “Element URL” is “http://www.dashboardjunkie.com/google-tag-manager” the new variable “Click URL Host Name” will return the value “dashboardjunkie.com”.