Show Menu

使用方 tl()

You can use the tl() method to track custom elements and to configure overlay rendering for dynamic content.


Using the tl() as part of the Activity Map AppMeasurement module lets you track any object that is clicked on, even objects that are not anchor tags or image elements. 使用,可以追蹤不會產生頁面載入的任何自訂元素。
In the tl() method, the linkName parameter that is currently used to identify the exit links, custom links, etc. 也將用來識別 Activity Map 變數的連結 ID。,linkType,linkName,variableOverrides)

In other words, if you use to track your custom elements, the link ID is pulled from the value passed as the third parameter (linkName) in the method. 無法從 Activity Map 預設追蹤 所用的標準連結追蹤演算法提取這個值。


從 HTML 元素的點按事件直接呼叫 函數時,Activity Map 可以在載入網頁時顯示該元素的覆蓋圖。範例:
<div onclick=",'o','Example custom link')">Example link text</a>

Whenever any web page content is added to the page after the initial page load, the tl() method is called indirectly and we cannot display overlays for that new content unless it is expressly activated/clicked. 之後會從 Activity Map 觸發新的連結收集程序。
When the tl() method is not called directly from the HTML element's on-click event, Activity Map can only display overlay once that element has been clicked by the user. Here is an example where the tl() method is called indirectly:
<div onclick="someFn(event)"></div>
<script>function someFn (event)
{,'o','Example custom link');

The best way for Activity Map to overlay dynamic content links is to have a customized function set up to call the same function whose return value is passed to . 例如:
var originalLinkFunction =; = function(element,linkName) {
    return linkName ||      // if this is a call, just return string passed
        makeLinkName(element) || // this is ActivityMap reporting time
        originalLinkFunction(element,linkName); // our custom function didn't return anything, so just return the default ActivityMap Link

<button type="button" onclick=",'o',makeLinkName(this)">Add To Cart</button>

此處,在呼叫時,我們已覆寫 函數,以執行下列三個事項其中之一:
  1. 若傳遞的是 linkName, 會由 呼叫,因此僅傳回 以 linkName 傳遞的內容。
  2. 此為 Activity Map 於報告時間所呼叫的項目,所以 linkName 未曾傳遞成功,因此採用連結元素呼叫 makeLinkName()。此為非常重要的步驟 –「makeLinkName(element)」呼叫應與 <button> 標記中 呼叫的第 3 引數相同。這表示當系統呼叫 時,我們會追蹤由 makeLinkName 傳回的字串。當 Activity Map 報告在頁面上的連結時,會使用相同的呼叫產生連結。
  3. 最終解決方案是僅傳回預設 ActivityMap 連結函數的原始傳回值。在預設情況下,保留此參考備用以便呼叫,可協助您僅需覆寫或寫入 makeLinkName 的自訂代碼,而不需針對頁面上所有連結提出連結傳回值。