此插件由 Adobe Consulting 团队提供,旨在帮助您从 Adobe Analytics 中获取更多的价值。Adobe 客户关怀团队不提供对此插件的支持,包括安装或疑难解答。如果您需要关于此插件的帮助,请与您组织的 Adobe 客户团队联系。他们可为您安排与顾问会面以寻求帮助。
getVisitDuration
插件可跟踪访客在某个时间点之前在网站上停留的时间(以分钟为单位)。如果您希望跟踪截至某个时间点为止访客在网站上停留的总时间,或跟踪访客执行某项活动所用的时间,Adobe 建议您使用此插件。此插件不会跟踪事件之间的间隔时间;如果需要使用此功能,请使用 getTimeBetweenEvents
插件。
Adobe提供了一个扩展,允许您将最常用的插件与Web SDK结合使用。
getVisitDuration
尚不支持在Web SDK的手动实施中使用此插件。
Adobe提供了一个扩展,允许您将最常用的插件与Adobe Analytics一起使用。
如果您不想使用“常用Analytics插件”插件扩展,则可以使用自定义代码编辑器。
在实例化(使用 s_gi
)Analytics 跟踪对象后,将以下代码复制并粘贴到 AppMeasurement 文件中的任意位置。在您的实施中保留代码的注释和版本号可帮助 Adobe 对任何潜在问题进行疑难解答。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getVisitDuration v2.1 */
function getVisitDuration(){if(arguments&&"-v"===arguments[0])return{plugin:"getVisitDuration",version:"2.1"};var d=function(){if("undefined"!==typeof window.s_c_il)for(var c=0,b;c<window.s_c_il.length;c++)if(b=window.s_c_il[c],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof d&&(d.contextData.getVisitDuration="2.1");window.cookieWrite=window.cookieWrite||function(c,b,f){if("string"===typeof c){var h=window.location.hostname,a=window.location.hostname.split(".").length-1;if(h&&!/^[0-9.]+$/.test(h)){a=2<a?a:2;var e=h.lastIndexOf(".");if(0<=e){for(;0<=e&&1<a;)e=h.lastIndexOf(".",e-1),a--;e=0<e?h.substring(e):h}}g=e;b="undefined"!==typeof b?""+b:"";if(f||""===b)if(""===b&&(f=-60),"number"===typeof f){var d=new Date;d.setTime(d.getTime()+6E4*f)}else d=f;return c&&(document.cookie=encodeURIComponent(c)+"="+encodeURIComponent(b)+"; path=/;"+(f?" expires="+d.toUTCString()+";":"")+(g?" domain="+g+";":""),"undefined"!==typeof cookieRead)?cookieRead(c)===b:!1}};window.cookieRead=window.cookieRead||function(c){if("string"===typeof c)c=encodeURIComponent(c);else return"";var b=" "+document.cookie,a=b.indexOf(" "+c+"="),d=0>a?a:b.indexOf(";",a);return(c=0>a?"":decodeURIComponent(b.substring(a+2+c.length,0>d?b.length:d)))?c:""};d=(new Date).getTime();var k=cookieRead("s_dur"),a=0;if(isNaN(k)||18E5<d-k)k=d;a=d-k;cookieWrite("s_dur",k+"",30);if(0===a)return"first hit of visit";a=Math.floor(a/6E4);return 0===a?"less than a minute":1===a?"1 minute":a+" minutes"};
/******************************************** END CODE TO DEPLOY ********************************************/
getVisitDuration
函数不使用任何参数。它会返回以下任一值:
"first hit of visit"
"less than a minute"
"1 minute"
"[x] minutes"
(其中 [x]
是自访客登录网站后所经过的时间,以分钟为单位)此插件将创建一个名为 "s_dur"
的第一方 Cookie,用于记录自访客登录网站起所经过的时间(以毫秒为单位)。该 Cookie 将在处于非活动状态 30 分钟后过期。
// Always sets eVar10 to the number of minutes passed since the visitor first landed on the site
s.eVar10 = getVisitDuration();
// Checks if the events variable contains the purchase event.
// If it does, sets eVar56 to the number of minutes between the start of the visit and the time of purchase
if(inList(s.events, "purchase")) s.eVar56 = getVisitDuration();