Using s.linkTrackVars and s.linkTrackEvents

The key to a successful link tracking implementation is understanding the s.linkTrackVars and s.linkTrackEvents variables. This lets you pass custom variable values on user actions.

If you are implementing custom link tracking and are setting custom variables and events, make sure that your s.linkTrackVars variable contains a comma-separated list of all variables that you are passing, including the events variable. Make sure that s.linkTrackEvents includes a comma-separated list of all events that you are passing.

Setting s.linkTrackVars and s.linkTrackEvents does not actually set these variables/events, it only prepares the Analytics code to do so. You still need to set the variables manually, as shown in the example below:

<script language="javascript">
function customLinks () {
	var s=s_gi('myreportsuite');
	s.linkTrackVars="prop1,eVar7,products,events";
	s.linkTrackEvents="event5,event9";
	s.prop1="Link Click";
	s.eVar7="my_page.html";
	s.events="event5";
	s.tl(true,'o','Custom Link Click');
}
</script>
<a href="my_page.html" onclick="customLinks();">My Page</a>

Notice that events is listed in the s.linkTrackVars variable. The individual events that may be passed are included in the s.linkTrackEvents variable and are also included within s.events later in the function. Each of the variables that are passed are listed in s.linkTrackVars before they are populated later in the function. Also, "event9″ has been included in s.linkTrackEvents, but has not been included in s.events. It is not recorded, but could be recorded if the user had chosen to set s.events="event5,event9."

Automatic file download and Exit link tracking work differently. The s.linkTrackVars and s.linkTrackEvents are included in the standard s_code.js file, and both are set to none. These variables are typically left set to none in the s_code.js file so that automatic link tracking, unlike custom link tracking, uses the s.linkTrackVars and s.linkTrackEvents values that you set in the global JavaScript file. They also pass whatever the existing values of those variables are whenever a file download or Exit link is recorded.

Consider the example where s.channel="Home" when the page loads, and where s.linkTrackVars="channel" in your s_code.js file. If a user clicks to download a file, automatic file download tracking passes data into Analytics, including the value of s.channel that was set on page load. "Home" is passed a second time, leading to inflation in page view data for this value in the Site Sections report.

Adobe strongly recommends leaving the s.linkTrackVars and s.linkTrackEvents set to "none" in the global JavaScript file and setting them explicitly as necessary with your custom link tracking implementation.