Tracking clicks to external sites and internal documents

Tracking pageviews to a website was the original analytics metric to report web site use.  A pageview is defined as the number of times a page is loaded by a browser. While it’s a good measure for macro-level volume of a site for a given time period, it’s not necessarily a good metric for unique traffic or traffic at an individual visitor level because visitors to a site may visit the same page multiple times.

Another limitation of pageviews is tracking clicks to links that go to external sites and documents that may download to a browser. When this occurs there is no page loaded and thus no pageview generated. In fact, this type of user event does not show at all in pageview reports.

The solution is to track clicks to external links and downloads as events. Events are visitor interactions that happen independent of a pageview although they may also generate a pageview. Common visitor actions that I track on some web sites are clicks on links, clicks on buttons, video plays, and document downloads.

Within Google analytics you can define events with the following syntax (I’m using a simple hyperlink here):

<a href=”http://destination/URL or relative path” onclick=”_gaq.push([‘_trackEvent’, ‘EventCategory’, ‘EventAction’,’EventLabel’]);”>Link Text</a>

EventCategory = a grouping of event types that you chose (i.e. Buttons, Links, Documents,Videos)
EventAction = a description of what the user did (i.e. Clicked, Downloaded, Played)
EventLabel = a unique name you give to identify the event in the analytics reporting tool.

Within Google Analytics the event results are located by selecting Content → Events in the left-side navigation panel.

The Events Overview screen showing the high level event categories that have tracking data

The Events Actions screen showing the actions tracked for a specific event category