Skip to content

The following button has a special class and data attributes that can be easily used with GTM to log events. Because the data attributes are generic, they can be applied to any element in the DOM (along with the listener class) to easily add events to elements site-wide with minimal development effort).

 

The DOM for the button is the following:

 

<a href="http://apple.com" target="_blank" class="pp-button pp-button-ga-event" role="button" data-ga-category="my_cool_category" data-ga-action="button_click" data-ga-label="on_the_page">
<span class="pp-button-text" id="mce_32" style="position: relative;" spellcheck="false">This button right here</span>
</a>