There are many ways how to track button clicks with Google Analytics. Also, I had to find a way how to accomplish it across my web. That´s why I describe how I managed it to work.

The right Google Analytics Tracking Code

The first condition was to find the right Analytics Tracking Code. When I used basic Tracking Code, I wasn´t able to track Analytics Events. So, this is the Tracking Code that works in my case:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-XXXXXXXXX-X', 'auto');
  ga('send', 'pageview');
</script>

Notice the highlighted line number 6. Instead of “UA-XXXXXXXXX-X” insert your Analytics Tracking ID.

Tracking Button/Link Clicks using Analytics Events

Tracking various Button/Link Clicks is possible using Events in Google Analytics. If there is a proper Tracking Code installed on your website, let Analytics know about Button/Link Clicks. Send it an event like this:

<a onclick="ga('send', 'event', { eventCategory: 'YourCategory', eventAction: 'YourAction', eventLabel: 'The Event Label'});" href="#" target="_blank">THE BUTTON/LINK</a>

Use onclick Event in your HTML code. It will execute needed JavaScript when an element is clicked – button or link in our case. There are some Event fields to be described:

  • eventCategory: It´s typically the object that is interacted, for example the Button, Link, Video, etc.
  • eventAction: This is the type of interaction, for example Click
  • eventLabel: This is useful for categorizing your event, it could be for example Demo Download

It´s up to you to mark the tracked Events. The fields are not predefined 🙂

Where to use

Where to use it? It´s up to you too, use it for example to track:

  • Downloads,
  • Signups,
  • Logins,
  • Outbound Link Clicks,

In my case, I track Outbound Link Clicks. I have landing pages with product description. Then there is a CTA (Call to Action) button to buy the product. It redirects to a page with a list of external shops, like Amazon, Google Play, iBookStore and so on. I have to track these link clicks for further shops performance analysis.

Send Analytics Events to AdWords as Conversions

I use Google AdWords to make some promotion. I found out that it would be very beneficial to track AdWords Conversions too when someone clicks on some of the external shop ‘s button. Check how to set Analytics Goals based on Event Tracking and send it as Conversion to Google AdWords here >>

Dodo Basnak - Real Marketing Strategy Founder  

Dodo Basnak

Real Marketing Strategy Founder
Questions? Email me:
info[at]realmarketingstrategy[dot]com