How to Track Link Clicks Using Google Analytics +Tag Manager

How to Track Link Clicks Using Google Analytics Google Tag Manager
  • Save

If you’re promoting your course, ebook, affiliate products, or otherwise linking out to other websites, you might want to track the behavior of the users and know whether the visitors to your site or webpage are actually clicking on those links or not. So, to do that, you need to find a way to track link clicks.

The amazing news is that tracking these links or button clicks is not difficult. It can simply be done in just a few short steps using Google Analytics and Google Tag Manager. You’ll be able to easily track how many visitors clicked on each button, internal or external link throughout your site. With this, you can use the results to optimize your outbound links for better performance and a bigger SEO (Search Engine Optimization) boost.

In this article, first, we will discuss why you should track link clicks. Then we’ll move towards a step-by-step guide on how to track link clicks using Google Analytics and Google Tag Manager. 

Let’s dive in!

Learn how to track #link clicks in your #website

Every person wants to build a high-converting CTA (Call to Action) for their website that makes them tons of money.

So the question is, how do you track your visitor’s actions and optimize your content so that you can capture them in your sales funnel? 

That means you shouldn’t just focus on the big CTAs. You should also focus on how elements like links, buttons and smaller call to actions perform on your blog posts and contribute to the overall customer experience.

If you don’t know which elements of your content are contributing or distracting your customer experience, you’ll never be able to create the kind of blog posts that truly bring conversions.

So individual links on your blog post are a matter of your customer’s lifetime value.

Individual #links on your #blog post are a matter of your Customer’s Lifetime Value.

And if your brand relies on affiliate links to help share content and increase your brand’s reach, then not knowing how many clicks you get will make it impossible to bring up revenue appropriately.

This is the major reason to track these link clicks and actions on your blog posts so that your content, links, and CTAs all work together to help elevate your sales.

And most importantly, one of the best reasons to track outbound links is the fact that it’s so simple to implement.

You need to think by yourself, does it make sense to not track the activities for which you are putting your time and money? Like the companies purchase sales tracking software to track their salesperson and sales number, in the same way, you need to track your visitors online to optimize the results.

To understand tracking clicks on the links, we need to know about Google Tag Manager, since it’s the easiest and most convenient way to track link clicks.

Google Tag Manager is a free tag management system (created by Google) that allows you to quickly and easily update measurement codes and related code fragments. In simple terms, it manages JavaScript and HTML Tags.

GTM allows marketers to create and monitor tags on a user-friendly interface, without the need to write code.

The most significant benefit of GTM is being able to have full control over monitoring and measuring data and reducing the possibility of human error.

Some of the benefits of Google Tag Manager are:

  1. Less dependency over developer
  2. Fast deployment of tracking codes
  3. Ease of operation through an intuitive GTM interface
  4. Version control to track changes through a GTM account
  5. Preview and Debug mode to test tags that are firing on the page before making anything live.
  6. GTM makes sure your Google Analytics code is always up-to-date (no need to manually update the code when Google makes changes)
  7. User management that allows user permissions (defining the level of their access)
  8. Ability to collect and monitor data (e.g. number of downloaded PDF documents, clicks on links, exit links, views of YouTube video content on the site, interactions on the contact form, clicks on CTA buttons, etc.)

Google Tags

Now, let’s understand Google Tags to easily understand what GTM can be used for.

What is the essential thing in managing a business?


Your business and all businesses depend on accurate and measurable data.

In order to get accurate data, you need a method to collect this data – Google Tags.

The function is to capture the data you choose and send it via GTM to Google Analytics, Google Ads, Facebook Pixel, and other third-party software.

Tags are snippets of website codes, and usually, they are JavaScript snippet codes.

Tags are your best friend in optimizing businesses.

They help you measure traffic, track visitor behaviour, track different kinds of clicks – button clicks, call clicks, pdf clicks, form submissions, sales on your shops, with them you can even track some not so often actions like copy and paste of text, or opening incognito tabs, turning off cookies, etc.

These little code snippets send information you want to track to your third-party software.

Manually coding all of this is difficult and time-consuming and can slow down a website with all the javascript code.

GTM makes this process easier.

All you need to do is embed code into your site pages once, and then each time you want to create a tag, GTM codes it and inserts it for you.

Continue Reading Below

Your site will run faster, it will not compromise data collection, the tags are risk-free, and you will get all the data without lethargy.

Identifying what you want to measure

Before even starting to work with GTM, you will need to build a list of what you want to measure on your website.

For example, the data you want to track on your website could be:

  • Clicks on buttons
  • Clicks on Affiliate Links
  • Clicks on the phone number
  • Clicks on the WhatsApp button
  • Thank you page (after an order)
  • Add to cart buttons
  • Remove from cart buttons/links
  • Checkout process / funnel
  • PDF downloads
  • YouTube video watched
  • Scroll Depth
  • or Anything….

So, the first step is to define actions that users will do on your website.

Actions that have value for you and the business, and then start deploying those tags.

Components of Google Tag Manager

You implement GTM on your website and connect Google Analytics.

Visitors come to the website, they do some actions there – read text, scroll down the text, visit pages, click on buttons, shop etc.

When that happens, GTM sends this data via tags and triggers it to Google Analytics, Facebook or other third-party software where you store the data.

Before going further, let us explain some crucial components.


Let’s say your GTM tags are children, well the Container is a safe house for them.

It’s a place that holds all Tags together.

It fires Tags according to the rules that are set up.

A container has its code that needs to be implemented on the website so that tags work, and data starts collecting.

The Container contains tags, triggers and variables.


Tags are a snippet of code that are designed to send data from your site to a third party.

For most users, those third-party sites are Google Analytics, Google Ads, Facebook Pixel, Hotjar.

Tags fire in response to an event.

Continue Reading Below

Those events could be button clicks, pdf download, affiliate link, add to cart, etc.

After the Tag is configured, use the triggers and variables to tell the tags what to do.


Triggers are rules that make sure that tags fire when you want them to.

The trigger is the central part of the tags, and Tag cannot be created without a Trigger.

Example: Let’s say you have a page called, and on that page, you have a button for a call to action to submit your email address.

The Container which has all the Tags and triggers for your website is loaded and primed when a visitor lands on the page “example page”. 

The Container will then continue to monitor the page to for the Tags and triggers specific to that page which in this example is to record an event when the call to action button is pushed to submit the email address.

When that Trigger takes place, the Tag is fired doing what you asked it to do, which might be to record the Event in Google Analytics that an email address was submitted.

The reason will want to track this is to measure “conversions” for your Google Ads account, so you can measure your conversion rate and conversion cost from your Google Ads marketing.

Google Tag Manager Installation

Now that we have covered the main concepts of Google Tag Manager, it is time to take you through implementation on a website.

Make sure you have a Google account (for example Gmail account), so that you can create a GTM Account with those usernames and passwords.

Create Google Tag Manager Account

Follow the next step to create an account:

Step 1: Sign in to GTM website ( with the email and password of your Google account.

Continue Reading Below

Step 2: Click on the button Create Account. Under one email address, you can create multiple GTM accounts, but it is essential to understand that: 1 GTM = 1 Website.

Step 3: Add a new account. In this step, name your account with the name of the website, and choose a country.

Step 4: Choose for what platform you want to track data. In the most common platform is Web, which is what we are covering today.

*Important: when you name the Container and account the account or Container cannot start with an “_” or contain a reserved character (!, @, #, $, <, etc.). 

The most common convention is to use the domain or if it is a subdomain the subdomain and name – OR just to make it easy to remember what the Container is for.

Install Google Tag Manager Code on a website

If you are not experienced with code or do not have access to your website or mobile app code, you may need to enlist the assistance of a developer for this step.

Developers can learn more at the Tag Manager Developer Quick Start Guide.

Once the account is created, the user interface will be opened with a special Container ID which needs to be implemented on the website. 

This is at the top of the page on the right as we show in the example below.

Install Google Tag Manager Code on a website
  • Save

Step1: Where do I find the container code to put on a website.

The code can be found by clicking on the ID which starts with “GTM-“, or in the “Admin” section under Install GTM.

The code will look like the next image.

Install Google Tag Manager Code on a website in your head section
  • Save

Step 2: Implement the code onto every page of your website.

Instructions for implementing GTM container code are straightforward, but if you’re unfamiliar with implementing code on your website, please talk with your developer.

The first code goes as in the top of a page in the <head> of the page.

This is crucial as it tells your website to load the GTM Container asynchronously.

This means that the first thing that happens when users come to your website GTM container begins to load with all of its Tags inside him as well as loading the other parts of your page at the same time.

This is important because we want to track all users, even those who come and leave after just seconds, and it ensures the page loads faster.

The second code is non-script part of the code, that needs to be placed immediately after the opening <body> tag.

This is not an integral part of the implementation. You can leave this code out because it tracks users without JavaScript.

The best practice is to have included on the page as some users don’t allow JavaScript, and you want to track all users, not just those that would enable JavaScript.

Here is the example of the code and how it looks in the page source:

Example of the code and how it looks in the page source:
  • Save

Step 3: Publish the Container

When the GTM is correctly installed on your website, the next step is to PUBLISH the Container by going back to the user interface and clicking on the button SUBMIT.

Publishing the Google tag manager Container
  • Save

Every time, you make changes in GTM, for example creating new Tags, editing Tags – you need to publish the Container so that changes go live, and that the data that is being sent to Google Analytics is accurate.

Preview and Debug Mode

The thing I most love in GTM is the preview and debug mode.

This feature means you don’t have to wait a couple of days to see if data in analytics being transferred correctly.

With preview and debug mode, you can check everything has worked immediately.

So how do we check this?

Step1: First click the Preview button, next to the Submit button.

Continue Reading Below
Preview and Debug Mode in GTM to track link clicks
  • Save

Step 2: After clicking on the button, preview and debug mode will open up in the user interface

Debug mode that open up in the user interface
  • Save

Step 3: And on the website, if the GTM container is installed correctly, it will open up the preview mode at the bottom of the screen on the website you have installed GTM.

Variables in Google Tag Manager
  • Save

If you see this windows opened, then you will know that the Container is placed correctly.

As you can see in the Preview window, there are 3 Tags that always fire when you come to your website.

Continue Reading Below

Those are:

  • Container Loaded
  • DOM ready
  • Window Loaded

After clicking and triggering other Tags, they will show in Summary.

Every Tag that fires has 4 dimensions in which you can analyze them:

  • Tags
  • Variables
  • Data layer
  • Errors

Google Tag Assistant

One additional tool for checking if Tags are working properly is the Google Tag Assistant.

Tag Assistant helps to troubleshoot the installation of various Google Tags, including Google Analytics,  and more.

Just navigate to any page, and Tag Assistant will tell you which Tags are present, report any errors we find and suggest improvements that can be made to your implementation. Most Google Tags are checked, including Google Analytics, Adwords Conversion Tracking, GTM and more.

Use Google Tag Assistant Recording to record a typical user flow to and through your website and instantly validate, diagnose, and troubleshoot issues with your Google Analytics implementation.

GTA is a chrome extension, and you can install it on this link

Google Tag Assistant
  • Save


This is short Checklist, so you don’t miss any steps in implementing GTM:

  1. Create Google Account
  2. Create GTM Account
  3. Implement GTM Container code on the website
  4. Submit the Container
  5. Turn on the preview mode and check if the Container is working
  6. Install Google Tag Assistant chrome extension and record pages on website and see if your GTM code is working

Google Analytics Installation via Google Tag Manager

Google Analytics is a powerful and free tool that gives you total control over your data and information about websites and visitors.

With Google Analytics, you can track:

  • Website traffic
  • Where do your users come from
  • Demographic and geographic information about your users
  • Users journey on your website
  • Individual pages and traffic for them
  • The time users spend on your website

With this in mind, implementing Google Analytics is an important step, culminating with tracking conversions for Google Ads.

Here is the easiest way to install Google Analytics via GTM.

Create New Tag

Step 1: Let’s go to GTM container workspace we just created, and start creating your first ever tag.

Creation of New Tag in Google Tag Manager for Setting up Link Click Event
  • Save

Step 2: Choose the Tag Type you want to create.

For this Tag, we need to create Google Analytics: Universal Analytics tag type.

Universal Analytics is the latest version of Google Analytics that was created by Google in 2012.

Choose tag type for creation of New Tag in Google Tag Manager
  • Save

Step 4: Next step is to define what type of tracking we will use for this Tag.

There are 7 types of trackings you can do, including:

  • Pageview
  • Event
  • Transaction
  • Social
  • Timing
  • Decorate Link
  • Decorate Form

For this Tag we choose Pageview.


Because the the starting point for Google Analytics tag will be to track all pageviews on a website.

Google Analytics in Google Tag Manager for Setting up Link Click Event
  • Save

Create new Google Analytics Variable

Step 5: After we choose the tag type, under Google Analytics Settings we need to create a new variable that we will call Google Analytics.

In this step the important part is to find the Google Analytics tracking ID and copy it in the Variable Configuration.

Google Analytics tracking ID can be found in Google Analytics, under the Admin section: Property / TrackingInfo / Tracking Code

 Type the code starting with UA into the box as shown in the example below.

Continue Reading Below
Enter tracking ID of Google Analytics to link it with GTM
  • Save

Create Trigger

A trigger listens and tells GTM when to fire.  In the case of a pageview, the trigger fires as the page is opened sending data to Google Analytics.

Step 6: After we created the variable, and configured our Tag we need to define fire this Tag.

Because it is a Google Analytics tag with pageview type, we want it to trigger on All Pages.

That means, we want to track All pages on a website.

Create Trigger in GTM
  • Save
Trigger Configuration
  • Save

Step 6: Save the created Tag with his Trigger.

And check it via Preview and Debug mode and via Google Tag Assistant.

The screenshot below shows the Tag and Trigger inside your GTM container. 

Tag Configuration
  • Save

The image above shows the Google Tag Assistant showing the different Tags that have fired on one of our blog pages in preview mode.


This is short Checklist to ensure Google Analytics is installed in GTM correctly:

  1. Check if GTM Container is installed properly
  2. Create Google Analytics tag and publish it
  3. Check via GTM if Google Analytics Tag is working with Google Tag Assistant
  4. Check with Realtime report in Google Analytics to see if its tracking users
  5. If there is an code in backend of the website, delete it after creating Tag in GTM
  6. Install Google Tag Assistant chrome extension and record pages on website and see if your Google Analytics code is working properly

In step 4 we outline checking that the code is firing in Google Analytics. 

The easiest way to do this is to log into Google Analytics and click “real-time” and you should be able to see yourself in Google Analytics accessing the page accessing the page we showed previously for Google Tag Assistant.

Event tracking via Google Tag Manager

The most important goal for businesses is tracking data, and we do that via Google Analytics.

In the previous section we learned how to connect Google Analytics and GTM with our website for accurate data.

But, what data do we actually use the most?

Of Course we need data about user demographic, pageviews, device reports ets.

But what is more important are  interactions on those pages.

Interactions that your users make, called events.

Events are not automatically tracked in Google Analytics that’s why we use GTM so that we can decide what events we want to track send event data to Google Analytics, once a visitor completes a certain action.

Let’s look at a button click.  The information we need to send to Google Analytics about a button click is:

  • Event Category – Button
  • Event Action – Button Click
  • Event Label – (Optional)
  • Value – (Optional)

Creating an event

To create events, the first you should PLAN which events you need.

For example we know there will be some clicks we want to track (ie buttons, links, add to cart etc).

Continue Reading Below

So in that case we need to enable built-in variables for those clicks, or other actions we need to track.

Built-in Variables

Step 1: In your GTM container, under section Variables choose the button “Configure” to configure all variables that you plan on using.

Built in variables
  • Save

Step 2 – Check the box next to the variables under “Clicks”

Configure built in variables
  • Save

Step 3 – After the Clicks are enabled in the built-in section, you can turn on preview and debug mode and try clicking on your website to see what happens.

Button Click Tracking

Let’s start with the easy Event.

In this section we will go through all the details of creating an event and all those steps later on can be used for creating similar events. The logic is the same.

Find a button you want to track.

Step 1: On your website the first step is to find clicks you want to track, clicks that are important to your business and that you are most likely wanting to track as a conversion.

Possibly these are the buttons that you want the user to click on.

Continue Reading Below

Find the class or ID of the button.

Step 2: Finding the Class or ID of the element we want to track, is pretty important because that differentiates one element from another. This is done in two ways:

  1. Open source code in your browser with right-click on the button and choose INSPECT (if your using chrome). This opens Developer Tools, allowing you to view the source code of the page.
image 16 - %title%- The Blue Oceans Group
  • Save

This means that we track the button that has class: button button-red

  1. Open the preview and debug mode on website, click on the button, open the variable of the action that happened in summary and find class or ID:
Link Click
  • Save

In this example, we found out that the action of clicking on the button is called Link Click, and that Link Click has class: button button-red, but does not have Click ID.

That is okay.

You need just one variable.

Also, you can use a variable like Click Element or Click Text.

Create a trigger for your button.

Step 3: After we find the variable that defines this button, we go back to GTM interface where we will create a trigger.

Triggers tell GTM when a tag should (or shouldn’t) fire.

For our button click Tag we need to create a trigger so that the Tag only fires when our button has been clicked.

There are 2 types of Click Triggers in GTM:

Create a trigger for your button.
  • Save
  • All Elements – tracks clicks on any element (For example image click, link click, button click, etc)
  • Just Links – tracks only link clicks

Step 4: In the GTM menu choose Trigger, then click on the plus and select the trigger type: Just Links.

After selecting the right type, we need to enter the click class of the element we found in the source, or preview and debug mode.

So, our Trigger will fire on Click Class that contains button button-red.

Trigger to fire on Click Class that contains button button-red.
  • Save

Creating Tag which will send data to our Google Analytics Account.

Step 5: Create New Tag and Name the Tag with something will help you remember what the Tag is for.

Step 6: Under Tag Configuration choose Universal Analytics as Tag Type.

Step 7: Choose tracking type: Select Pageview and change this to “Event”, because our click is an event.

Step 8: Now, we can choose how we want clicks on our buttons to be reported inside Google Analytics. As we talked before, Category and Action are required because those elements we use to send data to analytics.

In this case, we named them:

  • Category: Click
  • Action: Submit Agency

Step 9:  We need to select our Google Analytics settings variable that we already created when we added Google Analytics tag.

Step 10: And the final step is to add the Trigger that we already created.

Step 11: Click on Save.

add the trigger
  • Save

Below is a second example from our GTM account which tracks when someone signs up to our mailing list. 

This also tracks a button push.

GTM account which tracks when someone signs up to the mailing list.
  • Save

Importing Events to Google Analytics Goals.

Step 12: After the tag and Trigger are created we need make this Event be tracked in Google Analytics.

In the section Admin, choose Goals under View.

Press on the red button for creating a New Goal.

And Save it.

In Preview and Debug mode of GTM test if the clicks are tracked, and in Real Time report in Google Analytics check if the goals are tracked.

Now that you have set up the goal, with traffic going through the website, you can track this goal in Google Analytics under Conversions / Goals.

What if you have an affiliate website with a lot of different buttons that have the same CTA (Call To Action) and various affiliate links that can be found on different pages of your website?

Continue Reading Below

You probably need to track every affiliate link and every page, and every click.

If you start creating button click events for every single button, you will get lost, and the Google Analytics goal settings will not allow you to import that many goals per one view.

The important thing in GTM and Google Analytics is the accurate structure of every goal and Event.

Here is an easy way to track all clicks with one Tag and one Trigger.

Creating New Variable

We need to create 2 variables in this case.

 Step 1: First Variable we create is the one that says that the Element URL Is Outbound.

That means that the URL of an element we later choose via Tags and Trigger is the Affiliate Link or the link that sends from our website to another website.

Outbound clicks
  • Save

Go to Variables, click on creating New User Defined Variables.

Continue Reading Below

We need to choose Auto-event Variables that have type Element URL which Is Outbound.

Step 2: The second variable is for tracking Hostnames of affiliate links.

With this variable, we track domain.

Tracking Hostnames of affiliate links.
  • Save

With this variable, we will send to Google Analytics data of the affiliate links that were clicked.

Create Trigger

Step 3: Now we need to create a Just link Trigger that will fire every time an Outbound Link happens (or equals true).

Create Trigger
  • Save

This Trigger says: The Tag that I am embedded will fire every time an outbound link or affiliate link is clicked.

Create Tag

Step 4: The third step is creating a new Google Analytics tag.

Select Tag in GTM Menu, click New and name your Tag.

Step 5: Under Tag Configuration, we need to choose Universal Analytics as Tag Type.

When Tags are created for Google Analytics, tag type is always Universal.

Step 6: Select Pageview and change this to Event because our click is an event.

Now we can choose how we want clicks on our buttons to be reported inside Google Analytics.

Step 7: As we said previously, Category and Action are required because those elements we use to send data to analytics.

Category name: Outbound Links

Action: Built-in Variable – Click URL Hostname

Label: Built-in Variable – Page Path

With this, we send to Google Analytics data that says: Outbound Link just happened, on that specific page of your website and the user went to This Hostname.

Step 8: After creating Tag, just add Trigger we just created and save it.

Addition of Trigger
  • Save

Google Analytics Events

Step 9: Don’t forget to publish the Container.

After the Container is published, open the preview and debug mode on the website and see if the Tag is firing. It should look like this after clicking on the button:

Google Analytics Events
  • Save

After a couple of days you can see how this data looks in Google Analytics Reports.

Go to Google Analytics, choose Behavior in Google Analytics menu, then Events and Overview.

Continue Reading Below

You will see the outbound link in the event category, after clicking on it, you will get a window in which you can choose to look and analyse: category, action or label.

Tracking link clicks in Google Analytics
  • Save

Now you are tracking the journey of users who click on affiliate or outbound links.

Implementing Events to Google Ads

Most of the hard work is done! One more simple implementation is left.

As we all know, the majority of websites have PPC Campaigns with different kinds of goals and KPIs.

And for them to be measured, you need to track Conversions and Conversion rate of your PPC Campaigns.

In that case, let’s implement the goals we have created in Google Analytics directly to Google Ads.

Step 1: If your  Google Ads Account and Google Analytics accounts are not linked first link them. 

Login to Google AdWords  and click Tools and settings and then click “Linked Accounts”

Login to Google Adwords  and click Tools and settings and then click “Linked Accounts”
  • Save

Then click Google Analytics and then link to link your Google Analytics account (assuming both are under the same login).

Step 2: Go to your Google Ads Account and Import Conversions

Tracking in Google AdWords
  • Save
Import conversion in Google Adwords
  • Save

Step 3: Start tracking conversion in your Google Ads campaigns.


Links are a valuable addition to your website’s content – they improve your SEO and provide more value to your visitors. What’s more, you can easily track these links and find out which are either being clicked on or ignored.

Having this information, you can perform a lot of valuable optimizations, all of them a result of you learning how to track link clicks using Google Analytics and Google Tag Manager. For instance, you can optimize your affiliate links for more clicks, reach out to people who get a lot of those external clicks and suggest some partnership or other arrangement, plan your own content based on the external links that people click the most, and a lot more.

Do you have any questions about how to track outbound link clicks on your site, or how to understand the results? Ask away in the comments section below!

We would love to see your comments and thoughts on the article.  

What do you like and what have we missed?

Please leave these in the comments below.

Leave a Reply

Enter your details below so that the

14-Day Free Exclusive Coupon Code

can be applied for you.

Activate Your Exclusive

Semrush FREE Trial Now!

Share via
Copy link
Powered by Social Snap