Google Tag Manager Google Analytics Event for Tracking Phone Number Clicks in an Anchor Tag

As we work with clients on reporting, it’s a necessity that we set up a Google Tag Manager account for them. Google Tag Manager isn’t just a platform to load all your website’s scripts, it’s also a robust tool to customize where and when you wish to trigger actions within your site using any scripts that you’ve included.

Providing a monitored email externally on your site is a great way to make it easier for a visitor to drop your sales team an email. Here’s what that HTML anchor tag looks like:

<a href="https://martech.zonemailto:info@highbridgeconsultants.com">info@highbridgeconsultants.com</a>

Google Analytics Events offer the opportunity to measure events within a site. Events are a must for measuring interaction like clicking calls to action, starting and stopping videos, and other interactions within a site that don’t move the user from one page to another. It’s the perfect means to measure this type of interaction. To do so, we could modify the above code and add a JavaScript onClick event to append the event:

<a href="https://martech.zonemailto:info@highbridgeconsultants.com" onclick="gtag('event', 'click', { event_category: 'Mailto Link', event_action: 'Email Click', event_label:'https://highbridgeconsultants.com/contact/'})">info@highbridgeconsultants.com</a>

Notice that we’re also interested in the page that the email address was clicked from. That’s helpful to see which pages are driving the most engagement via email.

There are a few challenges with this. First, you may not have access to add the onclick code within the fields of your site’s content management system (CMS). Second, the syntax has to be correct so there are a lot of opportunities to get it wrong. Third, you’ll have to do it everywhere you have an email address listed on your site.

Event Tracking In Google Tag Manager

The solution is to employ the advanced capabilities of Google Tag Manager. As long as Google Tag Manager is implemented on your site, you never have to touch your content nor code to deploy event tracking like this. The steps to do so are as follows:

  • Trigger – Set up a trigger that is executed when a site visitor clicks on an email (mailto) link.
  • Tag – Set up an event tag that is processed each time the trigger is executed.

NOTE: A pre-requisite of this is that you already have a Google Analytics Universal Analytics Tag set up and properly firing on your site.

Part 1: Set Up Your Click Trigger

  1. Within your Google Tag Manager Account, navigate to Triggers on the left navigation and click New
  2. Name your Trigger. We called ours Mailto Click
  3. Click in the Trigger Configuration section and choose the trigger type Just Links

Google Tag Manager > Trigger > Just Clicks

  1. Enable the Wait for Tags with a default max wait time of 2000 milliseconds
  2. Enable Check Validation
  3. Enable this trigger when a Page URL > matches RegEx > .*
  4. Set this trigger fires on Some Link Clicks
  5. Fire this trigger on Click URL > contains > mailto:

Google Tag Manager Trigger Configuration mailto links

  1. Click Save

Part 2: Set Up Your Event Tag

  1. Navigate to Tags
  2. Click New
  3. Name your Tag, we named ours Tel Click
  4. Select Google Analytics: Universal Analytics

Google Tag Manager > New Tag > Google Analytics: Universal Analytics

  1. Set the Track Type to Event
  2. Type in the Category as Email
  3. Click the + sign on Action and select Click URL
  4. Click the + sign on Label and select Page Path
  5. Leave the Value Blank
  6. Leave Non-Interaction Hit as False
  7. Enter your Google Analytics Variable.
  8. Click the Triggering Section and select the Trigger you set up in Part 1.

Google Tag Manager - Google Analytics Event for Mailto Click

  1. Click Save
  2. Preview your Tag, connect your site, and click on your site to observe that the tag is fired. You can click on the tag Email Click and see the details that were passed.

google tag manager mailto event preview

  1. After you verify your tag is properly firing, Publish the tag to put it live on your site

Tip: Google Analytics doesn’t track events typically in real-time for your site so if you are testing the site and going back into your analytics platform, you may not observe the event being recorded. Check back in a few hours.

Now, regardless of the page of your site, every mailto link will record an event in Google Analytics when someone clicks the email link! You can also set that event up as a Goal in Google Analytics.

If you’d like to set this up for phone number clicks, be sure to read our previous article, Track Click to Call Links in Google Analytics Events Using Google Tag Manager.

© 2021 DK New Media, LLC, All Rights Reserved