google-tag-managerevent-tracking

How to create a trigger in Google Tag Manager that fires when either of the 2 elements present in <a> class are clicked


I would like to create a trigger in tagmanager that fires when either of the two elements present in are clicked.

Here's the source code to get a better understanding

<div class="col-lg-3 col-md-4">
      <a class="loan_for_travel" href="/loan-for-travel">
         <div><img class="img_travel_loan" src="https://images.pexels.com/photos/3760067/pexels-photo-3760067.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2"></div>
         <div>
            <p class="Travel"><span>Travel</span></p>
         </div>
      </a>
   </div>

I would like the trigger to get fired when either of the following things happen

  1. Image is clicked
  2. Travel (text) is clicked

I tried to fetch the parent class using a javascript but it returned null.


Solution

  • Both element are wrapped by the a tag. Why not just track the a?

    Or is there any specific requirement

    enter image description here