GTM Click URL Hostname
Loves Data
How can I get the hostname for a link click in Google Tag Manager?
Google Tag Manager has built-in variables you can use to capture the full URL someone clicks, but what if you only want to capture the domain (a.k.a. hostname) when someone clicks? Well, the good news is that it’s easy to capture using a user-defined variable.
Here’s the variable you’ll need to create in GTM:
Variable Type: Auto-Event Variable
Variable Type: Element URL
Component Type: Host Name
Enable Strip ‘www.’
That’s it! You can then use your user-defined click URL hostname variable in your tags and triggers.
Comments