While creating User-Defined Variables in GTM, one comes across with type of 'Auto-Event Variable'.

I am not entirely sure what it does, and how can it be utilized.

Also if I set it to element class then how is it different from say a 'click class' variable?

Please find the image of the variable attached.

enter image description here


There are probably some good resources that you can tap into for an explanation of what an auto-event variable (AEV) is (for example https://www.simoahava.com/analytics/auto-event-tracking-google-tag-manager). The way an AEV is described in that article is that it is

[variable] that can be used to refer to, for example, the DOM element where a click occurred.

The key phrase here is "where a click occurred". My own definition would be:

a variable that corresponds to the last element that was last interacted with.

If you want set up a trigger for a particular tag based on the element that was last clicked, and there are attributes of that element that you need for your trigger that might not, for some reason, be available through the Click or Link Click listener, then you would use an AEV. It gives you the ability to get a data-attribute, a class, ID, etc.

Element class can refer to the broader set of HTML elements that have a particular class, and Click class refers to the latest element that was interacted with (or clicked). By setting a trigger to include an AEV where it has an Element class of some value, it will fire the tag whenever ANY element with the particular element class is clicked. Now that I'm typing it out, it's a bit more confusing. I'll likely come back to this to revise it, but I hope it helps a bit.

  • Thanks for the answer. For example, if I use a (AEV - Element class) should it use a parent class or a child element class? In one of the tags that I am seeing a AEV - element class is capturing the child element and I do not why it is doing it. I do not know if having a span class or div class makes any difference for this variable. – ledzee Jan 28 '17 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.