When user clicks on a button a message is sent to the Data Layer, with the relevant information, however it doesn't contain Event

To set up a GTM trigger to fire on custom events I need to specify an Event name.

Is there a default name I can use? Or is there any other GTM trigger I should consider instead?

Attached is a screenshot of what the message looks like using DataSlayer chrome extension.

enter image description here


  • I have an idea. It's possible to create Cutom Data Layer Variable and use that as your trigger. In this case you create a trigger which fiers on all Events with regex like this: .* and then additional check your custom variable. To help you create that variable, can you please add screenshot from your GTM Preview window, under the tab Data Layers and Current values of the Data Layer after triggering the Data Layer? There should be all Data Layers in one. What I want to see is - process: "quote"
    – gintsg
    Commented Oct 31, 2018 at 1:13
  • Additionally, enable ckick All Elements trigger, but do not add anywhere. Maybe You can use that + custom variable.
    – gintsg
    Commented Oct 31, 2018 at 1:21
  • Another option is creat an event by updating your HTML as in this sample: <a href="#" name="button1" onclick="dataLayer.push({'event': 'button1-click'});" >Button 1</a> if you can't update HTML, then I would belive, that you can use click event. Try and see does it change anything.
    – gintsg
    Commented Oct 31, 2018 at 1:44
  • Thanks I will try to implement your first suggestion. The info in the GTM Preview window is the same as the screenshot provided.
    – Giacomo
    Commented Oct 31, 2018 at 11:39
  • unfortunately it didn't work. I have created the generic trigger of type Custom Event with regex .*, but it is not activated when the message is sent in the data layer.
    – Giacomo
    Commented Oct 31, 2018 at 12:00

2 Answers 2


Yes, you can by using HTML data attributes. When adding them to you HTML Markup you can automatically trigger events.

Also, you can try the CSS-selectors option. https://www.simoahava.com/analytics/matches-css-selector-operator-in-gtm-triggers/

I love this solution, but it comes with a downside: GTM is very picky what item you did click. So I created a jQuery script to look for the closest.

  var one = jQuery({{Click Element}}).closest('[html data attribute here]').attr("html data attribute here ");
  return one;

Does work like 99%. Of course not when JS is disabled.


As far as I know it is not possible to trigger a tag on a custom event from the data layer if the Event name is not in the object pushed in the data layer.

An alternative is to set up a trigger using Element id or Element class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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