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

How to Track Links in WordPress using Google Analytics

Last updated on by
Elegant Themes
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 http://www.example.com/out/ 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 lovers 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 »

Comments

  1. 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

  2. paul says:

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

  3. 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.

  4. 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.

  5. Gretchen Louise says:

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

  6. 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.

  7. 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.

  8. Michael Borger says:

    In your example above using Twitter, how would that be any different than seeing t.co 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.

  9. Kat Halushka says:

    Hi.

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

    Thank you for your time and help.

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.