ÃÛ¶¹ÊÓƵ

tl

The tl() method is an important core component to ÃÛ¶¹ÊÓƵ Analytics. It takes all Analytics variables defined on the page, compiles them into an image request, and sends that data to ÃÛ¶¹ÊÓƵ data collection servers. It works similarly to the t() method, however this method does not increment page views. It is useful for tracking links and other elements that wouldn’t be considered a full page load.

If trackDownloadLinks or trackExternalLinks are enabled, AppMeasurement automatically calls the tl() method to send download link and exit link tracking data. If your organization prefers to have more control over the links to track and their behavior, you can call the tl() method manually. Custom links can only be manually tracked.

The Web SDK does not differentiate between page view calls and link tracking calls; both use the sendEvent command.

If you use an XDM object and want ÃÛ¶¹ÊÓƵ Analytics to count a given event as a link tracking call, make sure that your XDM data includes:

  • Link name: mapped to xdm.web.webInteraction.name.
  • Link URL: mapped to xdm.web.webInteraction.URL.
  • Link type: mapped to xdm.web.webInteraction.type. Valid values include other (Custom links), download (Download links), and exit (Exit links).
alloy("sendEvent", {
  "xdm": {
    "web": {
      "webInteraction": {
        "name": "My Custom Link",
        "URL": "https://example.com",
        "type": "other"
      }
    }
  }
});

If you use a data object and want ÃÛ¶¹ÊÓƵ Analytics to count a given event as a link tracking call, make sure that your data object includes:

  • Link name: mapped to data.__adobe.analytics.linkName.
  • Link URL: mapped to data.__adobe.analytics.linkURL.
  • Link type: mapped to data.__adobe.analytics.linkType. Valid values include o (Custom links), d (Download links), and e (Exit links).
alloy("sendEvent", {
  "data": {
    "__adobe": {
      "analytics": {
        "linkName": "My custom link",
        "linkURL": "https://example.com",
        "linkType": "o"
      }
    }
  }
});

The ÃÛ¶¹ÊÓƵ Analytics extension has a dedicated location to set a link tracking call.

  1. Log in to using your ÃÛ¶¹ÊÓƵID credentials.
  2. Click the desired tag property.
  3. Go to the Rules tab, then click the desired rule (or create a rule).
  4. Under Actions, click the desired action or click the ‘+’ icon to add an action.
  5. Set the Extension drop-down list to ÃÛ¶¹ÊÓƵ Analytics, and the Action Type to Send Beacon.
  6. Click the s.tl() radio button.

You cannot set any optional arguments in the Analytics extension.

s.tl() method in AppMeasurement and the Analytics extension custom code editor

Call the s.tl() method when you want to send a tracking call to ÃÛ¶¹ÊÓƵ.

s.tl([Link object],[Link type],[Link name],[Override variable]);

The link object argument determines if the browser waits up to 500ms before navigating away from the page. If an image request is sent sooner than 500ms, the page immediately navigates to the clicked link.

NOTE
AppMeasurement automatically enables the useBeacon variable for exit links, making this argument no longer needed in modern browsers. This argument was used more commonly in previous versions of AppMeasurement.
  • this: Wait up to 500ms to give AppMeasurement time to send an image request. Default value.
  • true: Do not wait.
// Include a 500ms delay with an exit link
s.tl(this,"e","Example exit link");

// Do not include a 500ms delay with an exit link
s.tl(true,"e","Example exit link");

The link type argument is a single-character string that determines the type of link tracking call. There are three valid values.

// Send a custom link
s.tl(true,"o","Example custom link");

// Send a download link
s.tl(true,"d","Example download link");

// Send an exit link
s.tl(true,"e","Example exit link");

The link name argument is a string that determines the link tracking dimension item. When using the Custom link, Download link, or Exit link dimensions in reporting, this string contains the dimension item. If this argument is not set, the linkURL variable is used.

// When using the Download link dimension, this method call increases the occurrences metric for "Sea turtle PDF report" by 1.
s.tl(true,"d","Sea turtle PDF report");

Variable overrides (optional)

Lets you change variable values for a single call. See variable overrides for more information.

var y = new Object();
y.eVar1 = "Override value";
y.linkTrackVars = "eVar1";
s.tl(true,"o","Example custom link",y);

Examples and use cases

Send a basic link tracking call directly inside an HTML link:

<a href="example.html" onClick="s.tl(true,'o','Example link');">Click here</a>

Use JavaScript to make a basic link tracking call using method arguments:

s.tl(true,"o","Example link");

You can consolidate link tracking code into a self-contained JavaScript function. Calls can then be made in the onClick function of each link. Set the following in a JavaScript file:

function trackClickInteraction(name){
  s.linkTrackVars = "eVar1,eVar2";
  s.eVar1 = name;
  s.eVar2 = s.pageName;
  s.tl(true,"o",name);
}

You can then call the function whenever you want to track a given link:

<!-- Use wherever you want to track links -->
<a href="example.html" onClick="trackClickInteraction('Example link');">Click here</a>
NOTE
Calling the tl() method indirectly can make Activity Map overlay reporting less convenient. You must click each link to register the function with the link element. However, Activity Map dimensions in Workspace are tracked the same.

If trackDownloadLinks or trackExternalLinks are enabled, AppMeasurement automatically makes a link tracking call if the correct filters match. If you also manually call s.tl() for these link clicks, you can send duplicate data to ÃÛ¶¹ÊÓƵ. Duplicate data inflates report numbers and makes them less accurate.

For example, the following function would send two link tracking calls for same link click (manual and automatic download links):

function trackDownload(obj) {
  s.tl(obj,"d","Example PDF download");
}

You can help prevent duplicate link tracking calls by using the following modified function. It first checks to see if a link object exists, and only sends a manual link tracking call if the link object is an empty string.

function linkCode(obj) {
  var lt = obj.href != null ? s.lt(obj.href) : "";
  if (lt=="") {
    s.tl(obj,"d","Example PDF download");
  }
}

Use the tl() method with Activity Map

You can use the tl() method to track custom elements and to configure overlay rendering for dynamic content. The linkName parameter is also used to set the Activity Map Link dimension.

When the tl() method is called directly from the HTML element’s on-click event, Activity Map can display an overlay for that element when the web page is loaded. For example:

<a href="index.html" onclick="s.tl(this,'o','Example custom link');">Example link text</a>

When the tl() method is not called directly from the HTML element’s on-click event, Activity Map can only display an overlay once that element has been clicked. For example:

<a href="index.html" onclick="someFn(event);">Example link text</a>
<script>
  function someFn (event) {
    s.tl(event.srcElement,'o','Example custom link');
  }
</script>
recommendation-more-help
b4f6d761-4a8b-4322-b801-c85b9e3be690