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.
Usage
To use the enhanced link attribution feature:
- Enable enhanced link attribution in the Admin UI of your Google Analytics account.
- Update your tracking code 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');
Customizing enhanced link attribution
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 id="sidebar"> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact Us</a></li> </ul> If the |
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');