2.1K members online now
2.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

How to track a multi level tags?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi all,


I want to track the below hyperlink but GA only return the click URL of the image which is sample.image.jpg.


Any idea how we can get the Click URL of the hyperlink ( if this is the case below?


<a href="">

<img src="http://sample_image.jpg" Class="GTM_Trigger">

Welcome link



2 Expert replyverified_user

Re: How to track a multi level tags?

Top Contributor
# 2
Top Contributor
You can't get the parent element with built-in variables so I think the easiest way would be to print an id attribute that has the link href (or the text you want to use to identify the link)
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: How to track a multi level tags?

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭
Use the GTM option of "Click target"
This will capture the URL the click leads to.

Re: How to track a multi level tags?

Top Contributor
# 4
Top Contributor
Hi Victor,

have you tried creating a Data Layer variable type with gtm.element.parentElement.href? - this should do the trick. You could basically achieve the same with a custom JS variable though syntax would differ.

Hope it helps.

Kind regards,
Web analyst @