Enhanced Link Attribution

Enhanced Link Attribution improves the accuracy of your In-Page Analytics report by automatically differentiating between multiple links to the same URL on a single page by using link element IDs.


To use the enhanced link attribution feature:

  1. Enable enhanced link attribution in the Admin UI of your Google Analytics account.
  2. Update your tag on each page to load the enhanced link attribution plug-in (called "linkid").

The following code shows how to load the enhanced link attribution plugin:

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'linkid');
ga('send', 'pageview');

The enhanced link attribution plug-in differentiates between links to the same URL using the element IDs of a link or a parent element, as well as a cookie. You can customize how far up the DOM the plug-in will look for an element ID, as well as the behavior of this cookie, by providing configuration options when loading the plug-in.

Here are the available options and their defaults:

Option Value Type Default Description
cookieName string _gali The name of the cookie
duration number 30 The maximum duration (in seconds) the cookie should be save for
levels number 3

The maximum number of levels in the DOM to look to find an existing ID. For example, the following links do not contain ID attributes, but the <ul> element (two levels up) does:

<ul id="sidebar">
  <li><a href="/">Home</a></li>
  <li><a href="/about">About</a></li>
  <li><a href="/contact">Contact Us</a></li>

If the levels option were set to 1, the "sidebar" ID would not be found and the link would remain anonymous.

The following example shows how to specify custom configuration options when using the enhanced link attribution plugin:

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'linkid', {
  'cookieName': '_ela',
  'duration': 45,
  'levels': 5
ga('send', 'pageview');