0

Is it possible to push the firing trigger's source or name to Data Layer as a variable for any tag?

Just for an instance, I have a tag with multiple firing triggers where only one trigger at time is fired perfectly without any issues. But to meet my needs, I should also push the trigger's source or name along with it track for Google Analytics: GA4 Event, would it be possible with any Data layer variable or JavaScript Variable?

My Tag and the firing triggers at GTM


I am seeking to set this up like a variable or data that can be pushed as a parameter or data layer. So, it would be useful for any other such scenarios in future too.

Any possible solution in terms of code or any guidance to existing settings shall be really appreciated.

1 Answer 1

0

Maybe not so complicated

If your Click - Footer Subscribe Link trigger condition is button.sub-footer

And Click - Header Subscribe Link trigger condition is button.sub-header

Then just create a custom variable

function(){
  var clickElement = {{Click Element}};
  if(clickElement.match("button.sub-footer")){
    return "Footer Subscribe Link";
  }else if(clickElement.match("button.sub-header")){
    return "Header Subscribe Link";
  }
  return undefined
}

So your GA4 event tag can get the information from this Variable

You might need to change the code inside to comply to your real html code or trigger.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank your for that, I actually came across through this of solutions earlier but primarily, I am looking for more like a permanent solution for any such instance.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.