A
A
Alex Helvetios2020-06-30 03:21:55
Google
Alex Helvetios, 2020-06-30 03:21:55

How to set up a trigger for clicking on an icon/button AND the container in which it is nested in Google Tag-manager?

The goal is to collect and send to analytics / retargeting all visitors who clicked on the twitter button. The task is seemingly trivial, but there is a problem in how the button is implemented:

<a class="a-class top-view" href="twitter.com">
   <i class="i-class"> ... </i>
</a>

5efa78e2e8547175374150.png
Visually , it looks like this: the transition itself is made in a , but the icon is displayed with a separate i tag . The a tag has margin/padding (yellow/green zones) in the style, meaning the icon itself does not take up all the "space" of the a tag . The button itself works flawlessly - pressing passes both a and i - everything is ok.
Accordingly, there are two cases - when the user clicked on i directly and when he did not hit / the hand twitched / tremor and clicked on the area around the icon, hitting a and still correctly switched.

The question is - how can I collect both of them with ONE trigger? Because action with tch. the view of conversion is the same.

I will list what I have already tried and write why it did not work, everywhere below "Trigger - Click - all elements - Some clicks" and then the parameters:

  1. It works only when you click on the area of ​​the a tag , clicking on the icon itself does not fix it.
    5efa7c65dd5ce203419345.png
  2. It works on an icon, BUT the icon class is also used, for example, in Shares on a blog on a website, so it is incorrect to use it separately - it will take into account both buttons in one action. Similarly with class a .
    5efa7d4720813493326100.png
  3. I did it later with the selector - it works on the icon, but does not work on the a tag. Conditions in triggers work AND (... fulfillment of all conditions ...), so adding another condition for aa-class is not an option.
    5efa7fed02ce0570248764.png


In general, this can be solved by making 2 triggers with container and icon selectors and both of them to hang on the tag, but if there are 5-6 such buttons + share buttons that are implemented in the same way + other buttons that just have "a > span", then do it is necessary one million triggers is horror. In my opinion there should be a more elegant option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynatik001, 2020-06-30
@Lynatik001

5efa8ea0cb9dc690940738.png
And so I tried:?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question