Browse By

How To Track Mailto Link Clicks in Google Analytics

With a simple piece of JavaScript code you can begin tracking the number of times a mailto link is clicked on your website and view them inside Google Analytics. You can take a step further and setup a goal in order to view the mailto click as conversions in your Google Analytics Acquisition report.

Step #1 – Place JavaScript Code

The code needs to be placed in the footer – before the closing </body> tag on all pages that you want to track. If you are using a WordPress website or blog, you can install a plugin which will insert the code on all your pages when you insert it once.

Simply insert the code below into your pages and Google Analytics will receive an event every time a link is clicked.

Code:

Note: Do Not copy the <code></code> tags, just the values inside them.

<code><script type='text/javascript'>

jQuery(function($){

// mailto function

$('a[href^="mailto:"]').click(function(){

ga('send','event','mailto','click','email clicked');

return true;

});

}); </script></code>

Step #2

To view the events in Google Analytics, using the main menu navigate to Behaviour > Events > Overview.

Step #3 – Setup a Goal

Goals are a better way of understanding if your users are taking the desired actions on your site, for example if you want more users to click on your mailto links, you can setup a goal and identify which channels are bringing in the most clicks so that you can focus your efforts on optimising that channel.

In order to setup the goal, click on ADMIN or the Cog icon in the bottom left of the GA main menu. On the right hand side of the screen, under the ‘View’ column, click on Goals.

Mailto link tracking in google analytics

Step #4 – Setup a New Goal

Click on the +New Goal button and on the first step of your new Goal setup, select ‘Custom’ and click continue.

Give your goal a suitable name eg. Mailto Clicks and select ‘Event’ under goal type and click continue.

Fill the fields out as follow (these values are taken from the JavaScript event code you inserted earlier):

Category: mailto

Action: click

Label: email clicked

Leave the ‘Equals to’ parameters as they are and click save. You are now set and your mailto clicks will be recorded as goals in Google Analytics.

Thanks for reading! Leave a comment below if you would like any further help.

Leave a Reply

Your email address will not be published. Required fields are marked *