Easy tracking outbound links with Google Analytics in SharePoint 2010 with Mavention Google Analytics Outbound Links Tracking


Web managers often ask themselves which links the visitors use when they leave the website. If you’re using Google Analytics on your public–facing website, you can easily track those outbound links. Find out how to easily track outbound links on your SharePoint 2010 website using Google Analytics with Mavention Google Analytics Outbound Links Tracking.

When analyzing the usage on your website, one of the important questions is which links your visitors use when they leave your website. Using this information allows you to understand which information your visitors are interested in and which they don’t find on your website. Knowing this you can add the missing content to your site and and increase the time your visitors spend on your website.

Probably every analytics system out there allows you to track outbound links. Google Analytics is no different. Depending on your requirements you can track either all outbound links or only those links that you are particularly interested in.

Tracking outbound links using Google Analytics is pretty simple and comes down to two things that you have to do. Those steps are described in detail in a Google Analytics Help article. Although it’s not that complex to implement, the challenging part is getting this to work with SharePoint 2010 Rich HTML content.

Google Analytics event tracking and SharePoint 2010

Tracking outbound links using Google Analytics is achieved by using the event tracking capability. For this an onclick event has to be added to each link you want to track. As I’ve described in detail in my previous article, the SharePoint 2010 Publishing HTML Field Type does not allow you to use the onclick attribute which is being removed each time you save the content of your Publishing Page. The solution to this challenge is similar to implementing event tracking using Google Analytics in SharePoint 2010 and for your convenience I wrapped it in a turn-key SharePoint 2010 Solution.

Mavention Google Analytics Outbound Links Tracking is a no-code SharePoint 2010 Sandboxed Solutions that allows you to easily track outbound links using Google Analytics. It’s up to you to define which outbound links should be tracked.

What’s in the box

Mavention Google Analytics Outbound Links Tracking Features listed on the Site Collection Features page

Upon installation of the solution three Site Collection-scoped Features are installed:

  1. Mavention Google Analytics Outbound Links Tracking – this is the core Feature that installs all scripts required for functioning of the solution and installs the UI for managing Google Analytics outbound links tracking on hyperlinks.
  2. Mavention Google Analytics Outbound Links Tracking jQuery registration – this Feature registers jQuery upon which Mavention Google Analytics Outbound Links Tracking scripts depend. You don’t have to activate this Feature if you’re using jQuery yourself.
  3. Mavention Google Analytics Outbound Links Tracking registration script – this Feature registers the tracking script responsible for transforming the CSS class with analytics information into an onclick attribute. This Feature should be activated unless you have referenced the tracking script (located at: ~SiteCollection/Style Library/Mavention/GAOutboundLinksTracking/Mavention.GAOutboundLinksTracking.js) yourself to for example limit the number of requests on your site.

How it works

Assuming you’ve correctly done the setup of the solution with your site, if you edit a Publishing Page and focus on a hyperlink, in the Behavior group you should see the new Track outbound link option available.

The ‘Track outbound link’ option available in the Ribbon

If you check the Track outbound link checkbox a CSS class called gatout will be added to the hyperlink.

Red arrow pointing from the ‘Track outbound link’ checkbox to the gatout CSS class in the HTML source view

After you publish the page, the gatout CSS class will be converted to an onclick attribute that will register each click on the link with Google Analytics.

Red arrow pointing to the onclick attribute on a hyperlink in HTML source view

With that, every time a visitor clicks on an outbound link that has the outbound link tracking enabled, that information will be registered in your Google Analytics account and you will be able to find out which outbound links your visitors are using when they leave your website.

Summary

Using Google Analytics you can track outbound links to get more information about what hyperlinks your visitors are using when they leave your website. As tracking outbound links is based on the Google Analytics Event Tracking capability, it cannot be used with Rich HTML in SharePoint 2010. Using the Mavention Google Analytics Outbound Links Tracking no-code SharePoint 2010 Sandboxed Solution, you can easily track outbound links in your website.

Download: Mavention Google Analytics Outbound Links Tracking (36,5KB, Sandboxed WSP)

Others found also helpful: