javascript 使用 Tealium 的 utag.view 和/或 utag.link 来动态加载元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27989765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 08:15:54  来源:igfitidea点击:

Use of Tealium's utag.view and/or utag.link for dynamically loaded elements

javascriptjqueryanalyticstealium

提问by MannfromReno

This may be a long shot but I'm looking for someone who has worked with the Tealium UDO (Universal Data Object). I have a search page with a Google Search Appliance, my utag_dataobject in the data layer that looks like this:

这可能是一个长期的尝试,但我正在寻找与 Tealium UDO(通用数据对象)合作过的人。我有一个带有 Google Search Appliance 的搜索页面,我utag_data在数据层中的对象如下所示:

var utag_data = {
   "country":"US",
   "language":"EN",
   "search_keywords": "blahblah",
   "search_results": "0"
}

The problem here is the search_resultsproperty has not had enough time to wait for the real results number to load so it is defaulting to 0instead of the real number 1200. I've read Tealium's documentation around the utag.view()and utag.link()and want to use one of these to update the search_resultstag. I tried:

这里的问题是该search_results属性没有足够的时间来等待实际结果编号加载,因此它默认为0而不是实际编号1200。我已经阅读了关于utag.view()和 的Tealium 文档,utag.link()并希望使用其中之一来更新search_results标签。我试过:

utag.link({'search_results':'1200'}); 

and

utag.view(utag_data,null,[12]); 

where 12 is the UID of the tag in Tealium but when using Omnibug in firefox I'm not seeing any updated values, but it is sending the click event to AT Internet.

其中 12 是 Tealium 中标签的 UID,但是在 firefox 中使用 Omnibug 时,我没有看到任何更新的值,但它正在将点击事件发送到 AT Internet。

Does anyone have any experience with this? Thank you in advance

有人对这个有经验么?先感谢您

回答by here

You can either wait to call the main utag.jsTealium script, or send along another data point using utag.linkor utag.view. It is not possible to "update" the initial utag_dataobject once sent.

您可以等待调用主要的utag.jsTealium 脚本,或者使用utag.link或发送另一个数据点utag.viewutag_data一旦发送,就不可能“更新”初始对象。

These methods are used to handle sending dynamic events/data. See additional discussion on the Tealium blog at ajax tracking.. when urls no longer change

这些方法用于处理发送动态事件/数据。请参阅在ajax tracking的 Tealium 博客上的其他讨论.. 当 url 不再更改时

From utag.link() and utag.view()on Tealium Learning

来自Tealium Learning 上的 utag.link () 和 utag.view()

Syntax

句法

The link and view methods allow you to pass three different parameters:

link 和 view 方法允许您传递三个不同的参数:

  • parameter 1: a JSON object

    utag.view({'search_results':'1200'});

  • parameter 2: a callback function (optional, may be set to null)

  • parameter 3: an array of Tags (optional: if used, these are the only Tags that will fire)

    utag.link( {'search_results':'1200'}, function(){alert("Only fired tag 12 with this call");}, [12] );

  • 参数 1:一个 JSON 对象

    utag.view({'search_results':'1200'});

  • 参数 2:回调函数(可选,可设置为null

  • 参数 3:标签数组(可选:如果使用,这些是唯一会触发的标签)

    utag.link( {'search_results':'1200'}, function(){alert("Only fire tag 12 with this call");}, [12] );

Notes:

笔记:

  • The utag_data object declared on initial page landing is not re-purposed with these calls. If data from the initial page landing needs to be used it will need to be re-declared and passed again in the method call. For example, if language:"en" was passed on page landing, if language is needed for a tag fired by a utag method call then language will need to be passed again.
  • utag.view() calls should not be called on initial page load - they should only exist in the dynamic content loaded within the page.
  • Global and Tag-scoped Extensions are executed during these calls. Pre-loader and DOM Ready extensions will not executed during these calls.
  • 在初始页面登陆时声明的 utag_data 对象不会重新用于这些调用。如果需要使用来自初始页面登陆的数据,则需要重新声明并在方法调用中再次传递。例如,如果 language:"en" 在页面登陆时传递,如果 utag 方法调用触发的标记需要语言,则需要再次传递语言。
  • utag.view() 调用不应在初始页面加载时调用 - 它们应仅存在于页面内加载的动态内容中。
  • 在这些调用期间执行全局和标记范围的扩展。在这些调用期间不会执行预加载器和 DOM 就绪扩展。