GTM Variable “Click URL Host Name”

<- Back to list of variables

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

  1. Click on “Variables” (in the left menu)
  2. Scroll down to “User-Defined Variables” and click “New”
  3. Fill in the below data
    GTM Variable Click URL Host Name
  4. Click on “Create Variable”

Done! A new variable named “Click URL Host Name” is now available.



Example:

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”.