We have a region in our website where we show two buttons: "Sign in" and "Sign up now" if the user is not signed in. If the user is signed in, we display a button "Access App". These buttons are dynamically created using Javascript, depending on whether the user is signed in or not.

How do I track clicks on these individual buttons in Google Analytics? Is this possible using GTM and the link click listener?

1 Answer 1


It's harder to do with dynamic buttons, but assuming you don't have a static CSS ID that you can target off of for each button, and that the button text doesn't change ("Sign In", "Sign up now", "Access App"), then, yes, you can use GTM and a link click listener to track these clicks. You may need to add some additional logic, via custom JS, to see if the button text matches. If you have multiple occurrences of those buttons on the same page, you could possibly check if they are within certain divs on the page as well, again using custom JS.

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.