Sure, happy to explain it again! What if I told you that you could sort of put a single tag or trigger to cover all your components, instead of making individual tags for each one? Sounds great, right? Well, this can actually be achieved very easily and is common practice with the dataLayer implementation in GTM!
Let me explain a little bit further. Consider you have different components like buttons, accordions, dialogues, messages and so on. You can actually group these components and create a specific tag/triggers for each group.
Take the messages as an example. But first, let’s say, a message can be of four types: success, info, warning or errors. Now, what you can do is create a structure like this using the data layer:
`
dataLayer.push({
‘event’: ‘message’,
‘action’: ‘shown or dismissed’,
‘type’: ‘success, info, warning, error’,
‘message’: ‘the actual text of the message’,
‘location’: ‘something like header, body, footer, console’
});
`
This structure essentially allows you to cover all your message components with just one dataLayer message template and one single tag/trigger in GTM. And the same goes for your other grouped components.
Essentially, this approach makes component handling a lot simpler from both, the front-end and the Google Tag Manager’s perspective. Hope this helps streamline your processes!