Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Track Links in WordPress using Google Analytics

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Track Links in WordPress using Google Analytics

Earlier, we wrote about how to install Google Analytics in WordPress, and we have received tons of questions from our users. One of the most commonly asked question was how to track links in WordPress using Google Analytics? Well in this article, we will show you how to track links in WordPress using Google Analytics.

Before we answer that question, lets first talk about why would you want to track links in Google Analytics?

The general idea people have about Google Analytics is that it tells you how many vistors and pageviews you are getting, where the traffic is coming from, and what content is popular on your website. All of that is correct. However, Google Analytics can also provide you information about what users do when they come on your website, which banners or links they click the most, what product placements are working better on your website, which social media campaigns are bringing you more traffic, etc. For example, let’s say that you have a page on your blog where you sell an ebook. You publicize this page through twitter, facebook, various banner placement on your website, email newsletter, etc. Without tracking those metrics, how do you know which method is working the best? Maybe you have the ad for your book in your sidebar, in your footer bar, and after your post content. By tracking those links, you can find which one is working the best. Maybe, the footer bar and the after post banner is working the best, but your sidebar ad is not. Then you should get rid of the sidebar ad and focus on the other two placements. Perhaps, you can try improving your ad and then do A/B testing. By tracking links, you can greatly improve your website by getting rid of items that don’t work and optimizing the ones that do.

Tracking links in Google Analytics using UTM Source

Google Analytics has this amazing feature called custom campaigns. To use custom campaigns, you add UTM parameters to your URL which are then recorded in your custom analytics report. Google Analytics even has a URL Builder tool where you can generate a URL with UTM parameters.

Generating a URL with UTM parameters in Google Analytics

In the example above we have created a link to be shared on Twitter, as a tweet.

  • utm_source parameter identifies the source of traffic this could be a site, a social media network, newsletter, app, etc. In this example we have used Twitter.
  • utm_medium parameter is used to describe what kind of medium we have used, in this example we have used a Tweet.
  • utm_campaign parameter to define a campaign name, slogan, promo code, etc.
  • utm_term parameter is used to identify paid search keywords.
  • utm_content You could be using a variety of content types in a campaign, this element allows you to differentiate among them.

To view stats for your custom campaigns go to Google Analytics Reporting » Traffic » Sources » Campaigns and you will see something like this.

utm source in Google Analytics reporting

Tracking Out-going Links with Google Analytics

With Google Analytics, you can also track outbound links on your website. Outbound links are the links which take visitors from your website to some other site on the web. Understanding which external links are most often clicked on your website will help you understand what kind of information users are looking for. This will allow you to plan your content strategy accordingly.

Google Analytics does not track outbound links by default. To enable outbound link tracking, you need to add a little javascript to your website, and add a little code with each outgoing link that you want to track. This sounds like a lot of work if you want to track all your outgoing links. We will show you how you can enable automatic tracking of all outbound links in Google Analytics with WordPress.

First thing you need to do is install and activate the Google Analytics for WordPress plugin. If you already have Google Analytics code inserted in to your WordPress blog, remove that code. Once you are sure that your WordPress site does not have Google Analytics code, go to Settings » Google Analytics. Authenticate your Google Analytics profile or enter UA-Code manually. UA code is the unique identifier for each Analytics account you create. This UA code can be found next to your website’s profile in Google Analytics Dashboard.

Google Analytics for WordPress Plugin Authenticate with Google or Enter UA code manually

If you use an affiliate plugin to format your affiliate links into something like this then you will have to enable tracking of internal links as outbound links.

Tracking internal links as outbound links

To view the outgoing links, go to your Google Analytics account. In the sidebar click on Content » Events » Top Events. You will see outbound-article as the top event. Clicking on it will show you a list of outgoing URL(s) users clicked on your website.

Outbound Links Events in Google Analytics

Google Analytics is a very powerful tool. It not only helps you learn about your visitors and popular content, but you can also use it to develop strategies to further optimize your WordPress blog. We hope that you find this article useful. If you have used either the UTM tracker or outbound link tracking in the past, then let us know of your experience. If you are using something else, then please share that in the comments below. This way all of us can learn from each other.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Rick Sportel says:

    Really nice how easy this plugin allows one to set-up external link tracking for Google Analytics.

    Is there a way to tell the plugin to treat a different subdomain of the domain WordPress is installed on as an external domain/link as well?

    Fore example, many online shops nowadays have a blog, set-up like this:

    * Blog URL:
    * Shop URL:

    I have a set-up like this. But, when links point from the blog domain to the shop domain, these are not tracked as external links. I would really like to measure clicks on these links!

    Is it possible?

    If not, maybe add it to the features list?


  2. Troy says:


    I’ve set a few links via Google URL builder 5 days ago for affiliate links on a couple of blog posts but no data is coming through to GA and I don’t know why. I get plenty of traffic to this blog posts and it would be unlikely that nobody has clicked on the link. I’ve also clicked on the link a few times from different pc’s.

    Do you have any idea what the issue might be?

    Am I able to track links as an affiliate for a different website?

    I’ve watched the help videos online and read articles but can’t seem to find the fix.


    • WPBeginner Support says:

      If you have implemented the URLs correctly then the data would show up in your reports in 24 hrs. Make sure you are using the universal analytics code and not the legacy Google analytics code on your website.

      • Troy says:

        Sorry I don’t understand. What’s a legacy Google analytics code and how does it differ from a universal Google analytics code?

  3. Franco says:

    The question is – How to remove UTM parameters from URLs?
    Because a visitor can copy the link to bookmark or to share the link.

  4. TORY says:


    i added the google tracking ID 2 months ago and Analytics generates much data, if i “Remove that code”, and install the plugin you recommended, will I lose all the existing data that’s collected by Google analytics?

    thank you.

  5. lushani says:

    When you say, ‘If you already have Google Analytics code inserted in to your WordPress blog, remove that code’ do you mean the code that we enter in the headers and footers plugin as well? The one we did in this article of yours,

  6. Brian Ham says:

    Depending on what web server you are running on (IIS hosting php for
    example), and using integrated authentication, you can extract the user
    name inside your functions.php. Then, set a hidden field (again from
    your functions.php) in which you will reference from your javascript
    code for each of your pages. Or even easier, extract the user name
    inside your functions.php, generate javascript for GA, then add it to
    each one of your pages using the WordPress hooks/actions available to

  7. Brian Ham says:

    @Pooja, Depending on what web server you are running on (IIS hosting php for example), and using integrated authentication, you can extract the user name inside your functions.php. Then, set a hidden field (again from your functions.php) in which you will reference from your javascript code for each of your pages. Or even easier, extract the user name inside your functions.php, generate javascript for GA, then add it to each one of your pages using the WordPress hooks/actions available to you.

  8. Pooja says:

    We have an internal WordPress site, and about 25 users. Our current Google analytics set-up will show us how many times a page has been visited, but because everyone comes from the same IP address it thinks that it is basically one very industrious person clicking a lot.

    Does anyone have a strategy for tracking individual users?

    (They are all logged into WordPress as a function of our single sign on.)

  9. rajat says:

    sir this article is v ery helpful to me it makes my simple which was totally confused can you please tell about how to study the google analytics account how many visitors page session meaning and all other thanx again for that article please also write on the google analytics fundamental also

  10. paul says:

    Hello. Do you recommend for tracking the number of clicks for a url?

  11. Seth says:

    Hi I have followed your steps for outbound links and they dont seem to show up… The site is and I am pulling my hair out trying to understand what I am doing wrong. Its linking into the google analytics account but its not doing the events.

  12. Vernon McKenzie says:

    How can I have my facebook links from my WordPress website counts as hits on your site using Google Analytics. Is this possible ???

    • WPBeginner Support says:

      This is what the tutorial is about. Please take a look at it again, let us know if you don’t understand something and we will clarify it for you.

  13. Gretchen Louise says:

    What plugin do you recommend for clients who want to see at-a-glance Google Analytics stats in their WP dashboard?

  14. Joseph C says:

    If i have a specific link that I want to track (eg a side bar ad) how can I separate it in google anylitics from other places that link may show up (like in posts) so that i know that it is the side bar ad that is being clicked.

    • WPBeginner Support says:

      Use the URL Builder Tool mentioned in the article and choose sidebar_ad as the campaign medium. Generate URL and use it in your sidebar.

      • ThompsonPaul says:

        Actually, using campaign tagging parameters for internal links is a complete no-no.

        It totally screws up the accuracy of your analytics. Any click on the tagged internal link will be recorded as a new visit, artificially inflating your counts and messing with your engagement metrics. And as it strips the initial referrer, you won’t be able to track other important info about those visitors who click on the tracked link.

        Incoming external links are tracked with campaign parameters. Internal site actions must use events.

  15. George OBrien says:

    how could outbound tracking work for a tap to call? I’m trying to gather stats to show effectiveness of a wordpress mobile-optimized site?

    • Editorial Staff says:

      You can put a click counter on the tap to count button and track how many times the button was clicked.

  16. Michael Borger says:

    In your example above using Twitter, how would that be any different than seeing in the Traffic Sources > Sources > Referrals section of the standard Analytics report?

    • Editorial Staff says:

      You can use this technique to target at a deeper level for example which tweet at what time from which acccount brought the most traffic.

  17. Kat Halushka says:


    How long does it take for the event to show up in Analytics? Is it instant?

    Thank you for your time and help.

    • Editorial Staff says:

      Give it 24 hours to be accurate.

    • Ricardo H says:

      I think that you can view them instantly if you are in the “Real-Time” section of Google Analytics. In there there’s a view to see events as they happen. This is good for testing purposes, but for real metrics you would have to wait 24 hours like Editorial Staff said.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.