How To Extract Hostname of External Domain in Google Tag Manager
This blog post is based on the thread in GTM forum:
Let's say you link an image on your blog post to Justin Cutroni's website. Here's the image and the link that it goes to: http://cutroni.com/blog/wp-content/uploads/Screen-Shot-2013-09-30-at-10.45.44-AM.png:
In you go to GTM > Preview mode, you can now see this variable populated with cutroni.com
You can now create a trigger where:
Hostname does not equal your own website
Click URL matches RegEx jpg|png|svg|gif [in case you only want to capture image clicks to external domains - and know which domains did the traffic go to] AND click URL does not contain your own domain.
Once you have this, you can now setup an event where:
Category = Outbound image clicks
Action = {{page url}}
Label = {{External domain clicked on}}
and that's it.