The s.tl() Function - Link Tracking

File downloads and exit links can be automatically tracked based on parameters set in the AppMeasurement for JavaScript file.

If needed, these types of links can be manually tracked using custom link code as explained below. In addition, custom link code can be used to track generic custom links that can be used for a variety of tracking and reporting needs.

s.tl() Parameter Reference

Variable Description
this

The first argument should always be set either to this (default) or true. The argument refers to the object being clicked; when set to "this," it refers to the HREF property of the link.

If you are implementing link tracking on an object that has no HREF property, you should always set this argument to "true."

Because clicking a link often takes a visitor off the current page, a 500ms delay is used to ensure that an image request is sent to Adobe before the user leaves the page. This delay is only necessary when leaving the page, but is typically present when the s.tl() function is called. If you want to disable the delay, pass the keyword 'true' as the first parameter when calling the s.tl() function.

linkType
s.tl(this,linkType,linkName, variableOverrides, doneAction)
linkType has three possible values, depending on the type of link that you want to capture. If the link is not a download or an exit link, you should choose the Custom links option.
Type linkType value
File Downloads 'd'
Exit Links 'e'
Custom Links 'o'
linkName This can be any custom value, up to 100 characters. This determines how the link is displayed in the appropriate report.
variableOverrides (Optional, pass null if not using) This lets you change variable values for this single call, It is similar to other AppMeasurement libraries.
useForcedLinkTracking

This flag is used to disable forced link tracking for some browsers. Forced link tracking is enabled by default for FireFox 20+ and WebKit browsers.

Default Value

true

Example

s.useForcedLinkTracking = false
forcedLinkTrackingTimeout

The maximum number of milliseconds to wait for tracking to finish before performing the doneAction that was passed into s.tl . This value specifies the maximum wait time. If the track link call completes before this timeout, the doneAction is executed immediately. If you notice that track link calls are not completing, you might need to increase this timeout.

Default Value

250

Example

s.forcedLinkTrackingTimeout = 500
doneAction

An optional parameter to specify a navigation action to execute after the track link call completes when useForcedLinkTracking is enabled.

Syntax

s.tl(linkObject,linkType,linkName,variableOverrides,doneAction)
doneAction : (optional) Specifies the action to take after the link track call is sent or has timed out, based on the value specified by:
s.forcedLinkTrackingTimeout
The doneAction variable can be the string navigate, which causes the method to set document.location to the href attribute of linkObject. The doneAction variable can also be a function allowing for advanced customization.

If providing a value for doneAction in an anchor onClick event, you must return false after the s.tl call to prevent the default browser navigation.

To mirror the default behavior and follow the URL specified by the href attribute, provide a string of navigate as the doneAction .

Optionally, you can provide your own function to handle the navigation event by passing this function as the doneAction.

Examples

<a href="..." onclick="s.tl(this,'o','MyLink',null,'navigate');return false">Click Here</a> <a href="#" onclick="s.tl(this,'o','MyLink',null,function(){if(confirm('Proceed?'))document.location=...});return false">Click Here</a> 

Example

The following example of an s.tl() function call uses the default 500 ms delay to ensure data is collected before leaving the page.

s.tl(this,'o','link name');

The following example disables the 500 ms delay, if the user is not going to leave the page, or whenever the object being clicked has no HREF.

s.tl(true,'o','link name');

The 500ms delay is a maximum delay. If the image requested returns in less than 500 ms, the delay stops immediately. This allows the visitor to move onto the next page or next action within the page.

The following examples are for handling custom links on WebKit browsers:

<a href="..." onclick="s.tl(this,'o','MyLink',null,'navigate');return false">Click Here</a>
<a href="#"  onclick="s.tl(this,'o','MyLink',null, 
function(){if(confirm('Proceed?'))document.location=...});return false">Click Here</a>
Note: Uses of custom link code are often very specific to your Web site and reporting needs. You can contact your Adobe Consultant or Customer Care before implementing custom link code to understand the possibilities available to you and how best to leverage this feature based on your business needs.

The basic code to track a link using custom link code is shown in the following example:

<a href="index.html" onClick="s.tl(this,'o','Link Name')">My Page</a>
Note: The s_gi function must contain your report suite ID as a function parameter. Be sure to swap out rsid for your unique report suite ID.
Note: If the link name parameter is not defined, the URL of the link (determined from the "this" object) is used as the link name.

Analytics variables can be defined as part of custom link code.