Email, PDF, External & More | Tag Manager Link Click Tracking
Back to Mingle

Tracking Link Clicks with Tag Manager Part II: Examples

Posted in Search & Social — December 18, 2014

In Part I, we explained the basics of setting up link click tracking in Google Tag Manager. In Part II, we go into some specific examples.


Let’s first clarify the following universal elements:

universal link click elements
  1. Tag Name: Give the tag a name that makes sense to you.
  2. Tag Type: Select either “Universal Analytics” or “Classic Analytics”, depending on whichever you are using.
  3. Tracking ID You can either manually type your unique Google Analytics ID into this field (ex: UA-########-1) or use a convenient macro that plugs this in for you.
  4. Track Type: Select “Event” as the tag type.
  5. Assign Parameters: Here is where you choose the tag’s Category, Action, and Label.
  6. Firing Rules: Each tag always starts with a firing rule of Event Equals gtm.linkClick. Additional rules will specify the type of link.
firing rule equals gtm.linkClick

What changes for each tag?
Basically, only the Firing Rules, and potentially, the Tag Parameters (category, action, label).


Example 1: Track All Clicks on Any Email

Suggested Parameters
naming parameters

  • Category: Email Link Click – I manually named this, so it’s easy for me to see that this category includes any link on an email address.
  • Action: {{url}} – This is a macro. True to its name, the URL macro plug the URL of the page that the link click occurred on. For example, if someone was on the /about/ page, and clicked on an email address, then Google Analytics will record /about/.
  • Label: {{element url}} – Also a macro, this Element URL macro records the specific link that was clicked on. For example, if the user clicks on “”, that’s what Google Analytics will record.

Suggested Firing Rules
mail click firing rules

  • Event Equals gtm.linkClick: Always set this for all link click tags.
  • Element URL contains mailto: This is where the firing rules are truly specific to tracking clicks on email addresses. Every single email address links contains mailto: so this firing rule ensures that this tag only fires on clicks where links are “mailto” type email addresses.

Example 2: Tailor Tags for Individual Emails or Pages

Depending on your needs and individual preferences, you may not want to track all emails. Or, you may want to create more in-depth tags that give emails more concise parameter labels. Or – you may only want to track emails on some pages. There are endless variations on this theme, but here are a few ideas and examples:

  • Tracking Emails only on a Certain PageThe parameters can stay the same as the basic tag, but here’s how you’d edit the firing rule to be particular to one page:
    track emails on a specific pageFor example, if you want to only track email address clicks on the “about” page, you can add that the {{URL}} {{contains}} about. Depending on the format of the page, you can use a variety of different criteria – or even regular expressions – to isolate a URL or set of URLs.
  • Tracking A Specific AddressFor the tag itself, you can give the tag a unique name and also a unique category name.track a specific email address click

    For firing rules, you can isolate this to the email address itself. In this case, I used a regular expression to match sales/@. There are match types that could work here.

    match regex to tag rules


    Hopefully some of the above examples have helped you see that there’s a pretty simple pattern here of intuitively naming parameters and then just adjusting the firing rules for the specific link – or type of link(s) – you want to track. Here’s a simple tag and rule that can isolate to a PDF click:

    pdf click tag regex matches pdf

    In this general case, the rule is that the regex matches \.pdf (remember, when using regex you have to “escape” special characters like periods, etc, with a \ sign} – but you could get even more specific with this to match a specific PDF file name, or only PDFs on a group of particular pages, etc.


    Example 1: Track All External Links

    As with any tag, the parameters for this are really flexible – one suggestion is to configure as follows:
    tag config all external links

    The firing rule for this tag uses a regular expression to exclude clicks on your own domain: .*yourdomain\.com.* (Obviously, replace “yourdomain” with whatever your actual domain happens to be.)

    exclude your domain

    Example 2: Track Social Media Profile Links
    I personally prefer to narrow down external links certain types of links, such as for social media. Here’s one example of how to do that:

    social profile clicks

    Rules to Track all – or just some – Social Media Link Clicks:
    Here, we can track all social media link clicks by using a rule that the element URL matches the regex: .*facebook\.com.*|.*twitter\.com.*|.*instagram\.com.*|.*pinterest\.com.*|.*linkedin\.com.*|.*youtube\.com.*

    track all social media link clicks

    Or, instead of tracking all, you can just track clicks to your own social profiles using a rule of something like this:

    And so on. The difference is that instead of using a wild card on the end of the social profile (.*) that would match anything, you’re instead stipulating your own profile name, etc.


    Wouldn’t social media interactions, like Facebook likes, Pinterest pins, Twitter tweets, etc., also be classified as a gtm.linkClick event?

    Unfortunately, no. In order for social interaction tracking to work, you need to create a new type of social interaction event called socialInt. You’ll also likely need the help of a developer to push this event into the data layer:

    Google Tag Manager

    For additional details, please see Simo Ahava’s excellent post on how to track social media interactions.


    Sometimes, you will need highly specific rules that isolate a link to a specific attribute. For example, let’s say you want a tag that isolates social profile links in the footer only:

    footer link clicks

    If we examine the source code, we can see that these footer social media links have a special, unique class of stalk-icon:

    special link class for footer

    That means that when we create tag firing rules, we can just stipulate that the tag fires when any link matches this element class:

    firing rules match footer class

    For an even cleaner implementation (one that your dev will appreciate), instead of relying on the element class, you can stipulate custom data attributes that make this even easier and less-error prone to manage. For additional information, see Luna Metrics’ detailed post on tracking clicks with custom data attributes.

Written by .


  1. Wow! This blows my little introductory post on link tracking out of the water!

    Great reading though. It never even occurred to me put tracking links into PDFs or social media posts either. A real eye opener for me.

    Many thanks for sharing this. I have become far better informed for reading it.


    Steven Lucas

    Posted by Steven Lucas Internet Marketing Blog, January 10, 2015 | Reply

    • Hi Steven,

      So glad you found the info helpful! It was to me too even as I wrote it, sorting it all out and learning as I went along. Best of luck with your marketing efforts.

      Posted by Sarah Mackenzie, January 10, 2015 | Reply

  2. Hey guys, I just wanted to know how to do this in the new GTM layout… Now there are “triggers” instead of just defining “firing rules”, which is exactly the same but there are no “event” option in the fire on step.

    Posted by Patricio, April 10, 2015 | Reply

    • Hi Patricio,

      The triggers work a bit differently but overarching concept is the same. In fact, it’s simplified so it’s a lot easier to figure out!

      1. Go to Triggers => NEW
      2. Name the Trigger
      3. Under “Event”, select the type of event that matches whatever you are trying to do. I see options for: Page View, Click, Form, History Change, Custom Event, JavaScript Error, and Timer.
      4. Choose associated firing rules (hard to go into detail here since I don’t know what type or rule or tag you’re creating)

      Hope this helps…

      Posted by Sarah Mackenzie, April 14, 2015 | Reply

  3. Hi guys and gals,

    I stumbled across this post via Google search and am glad that I did. It cleared a few things for me but I have to say I am still REALLY frustrated with a product that should be so simple to work.

    I few months ago I started learning to program and even though I was able to understand more difficult concepts of data pointers in C++ and such I simply cannot wrap my head around a simple concept such as GTM. (In fact Id much rather write my own JS :))

    Im trying to use the new 2.0 interface to create simple mailto link tracking. What bugs me is the stup** terminology that they use and which seems inconsistent to me. Tags, triggers, variables, … used to be rules and macros.

    This is what I have:

    *Type: UA
    *Tag type: Universal analytics
    *Tracking ID {{GA tracking ID}}
    *Track type: event
    *Category: click
    *Action: mailto
    *Label: {{click URL}}
    *Fire on: Click
    *This trigger will fire your tag: mailto Click

    *Choose event: Click
    *Configure trigger
    Trigger type: Link click
    Wait for tags: 2000 mS
    Check validation
    *Enable when: Click URL contains mailto
    *Fire on: Page URL matches RegEx .*

    It simply will not work :(… Thanks for any info!

    Posted by alexander strbac, April 20, 2015 | Reply

    • Hi Alexander! We need to update these instructions to reflect Google’s new interface, I’ll need to rewrite to a brand-new post. Thanks for your patience as we work to do this.

      However, in the the meantime, I would head on over to the Google Tag Manager community on Google+: Everyone is extremely helpful and can help with this advanced troubleshooting.

      Posted by Sarah Mackenzie, May 2, 2015 | Reply

  4. Hello,
    I would like to track a picture that leads into two different URLs. It is up to the part of picture (pixels) you click on. Any ideas how to track this picture? Thank you!

    Posted by Anastasia, May 12, 2015 | Reply

    • Hi Anastasia,

      It sounds like you can just create a separate tag for each URL. Just have the rule based on whatever each URL is. The fact that different areas of the picture link to different places doesn’t have much to do with the tag itself. Instead, just focus each tag on where the link is pointing, tracking unique properties of that link. The element URL each rule can match “”, and then “”, etc.

      Posted by Sarah Mackenzie, May 12, 2015 | Reply

  5. Hi,

    I’ve followed your guide exactly with regards to Social Profile clicks. But for some reason, it won’t work. But I can get Page View tracking to work, so I know the set-up on the web site side is fine.

    My URL is

    And I would like to track people clicking on the social media links on the top right.

    I have also tried following another person’s tutorial in the past, but it didn’t work either. I’m quite new to GTM – is there something I would have missed?

    Posted by Albert, May 19, 2015 | Reply

    • Hello,

      My advice is to double check every single field and setting in both your tags and your rules. You may even want to just delete the associated tag and firing rules that aren’t working, and start over again from scratch while double-checking each step as you go. With GTM, it’s easy to make one simple mistake that messes everything up. A small typo, capitalization error, an accidental selection of the wrong drop-down option, etc, could cause a tag not to fire.

      Also, keep in mind that this tutorial is now outdated: If you’re using the new version of GTM, these instructions could be a little confusing.

      Posted by Sarah Mackenzie, May 21, 2015 | Reply

  6. Hi Sarah,

    This is a pretty awesome post. I have tried many times to implemented social media buttons tracking. What is a problem, that every time I tried with implementation on test website, everything was good. But, when I move tag and trigger on the live version of the website, trigger fires constantly, so I see a lot of Events for Social media links, which is not normal.

    All buttons are in a footer of the website, so I don’t know whether JavaScript makes some problems or something else. I am so confused because the test shows everything is working fine, but a live event on the live version totally goes nuts.

    Did you have problems like this?

    Thanks in advance!

    Posted by Vlada Cuk, January 31, 2017 | Reply

    • Hi Vladimir,

      It’s hard for me to tell exactly what’s going on from your description. I would try posting in the Data Studio forum and ask for more help, they have a fantastic community there and then you can share code from your site to get more in-depth feedback:

      Posted by Sarah Mackenzie, February 3, 2017 | Reply

Leave a Reply

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