使用此插件

getPercentPageViewed 函数使用以下参数:

  • pid(可选,字符串):等于当前页面的变量或值。默认为 Analytics AppMeasurement pageName 变量或当前 URL(如果未设置 AppMeasurement pageName 变量)。
  • ch(可选,布尔):如果您不希望此插件考虑在页面初次加载后对页面大小所做的任何更改,请将该参数设置为 false(或 0)。如果忽略,则该参数将默认为 true。在大多数情况下,Adobe 建议忽略该参数。

调用此函数时,不会返回任何内容;但是,会设置以下变量:

  • window._ppvPreviousPage:查看的上一个页面的名称。直到新页面加载完成后,才能获得当前页面的最终滚动测量结果。
  • window._ppvInitialPercentViewed:上一页面首次加载时查看内容所占的百分比。如果整个页面在首次加载时可见,则此值为 100
  • window._ppvHighestPercentViewed:访客查看的上一页面内容所占的最高百分比(以高度衡量)。访客在上一页面上向下滚动到的最远点。如果整个页面在首次加载时可见,则此值为 100
  • window._ppvFinalPercentViewed:在访客移至当前页面上时,上一页的可见内容的百分比。该值将大于或等于已查看内容的初始百分比,也将等于或小于已查看页面内容的最高百分比。
  • window._ppvHighestPixelsSeen:访客在上一页面上向下滚动时,所看到的总像素的最大值(以高度衡量)。
  • window._ppvFoldsAvailable:在上一页面上向下滚动时,可达到的“页面折叠”总量。如果整个页面在首次加载时可见,则此值为 1
  • window._ppvFoldsSeen:访客在上一页面上向下滚动时,所达到的“页面折叠”的最大值。此变量包括“页面顶部”折叠。如果整个页面在首次加载时可见,则此值为 1

将上述一个或多个变量分配给 eVar,以便在报告中查看维度数据。

此插件会创建三个第一方Cookie,它们将在浏览器会话结束时过期:

  • s_ppv:存储通过调用函数公开的每个值
  • s_tp:存储上一页的总像素高度
  • s_ips:存储上一页的初始滚动百分比

示例

// 1. Runs the getPercentPageViewed function if the page variable is set
// 2. Sets prop1 to the previous value of the page variable
// 3. Sets prop2 to the intial percent, the highest percent, and the final percent viewed; the number of folds available on the page, and the number of folds viewed ( of the previous page)
if(s.pageName) getPercentPageViewed();
if(_ppvPreviousPage)
{
  s.prop1 = _ppvPreviousPage;
  s.prop2 = "initialPercent=" + _ppvInitialPercentViewed + " | highestPercent=" + _ppvHighestPercentViewed + " | finalPercent=" + _ppvFinalPercentViewed + " | foldsAvailable=" + _ppvFoldsAvailable + " | foldsSeen=" + _ppvFoldsSeen;
}

// Given prop5 operates as a page type variable:
// 1. Runs the getPercentPageViewed function if prop5 has a value
// 2. Sets prop1 to the previous value of the page type
// 3. Sets prop2 to the initial percent viewed and the highest percent viewed.
if(s.prop5) getPercentPageViewed(s.prop5);
if(_ppvPreviousPage)
{
  s.prop1 = _ppvPreviousPage;
  s.prop2 = "initialPercent=" + _ppvInitialPercentViewed + " | highestPercent=" + _ppvHighestPercentViewed;
}

版本历史记录

5.1(2022 年 12 月 8 日)

  • 添加了 _finalPercentViewed 解决方案

5.0.1(2021 年 6 月 22 日)

  • 修复了某些特殊字符会导致插件中断的问题

5.0(2021 年 3 月 19 日)

  • 以上下文数据形式添加了版本号。

v4.0(2019 年 10 月 7 日)

  • 新增了 s._ppvFoldsSeens._ppvFoldsAvailable 解决方案

v3.01(2018 年 8 月 13 日)

  • 修复了一个页面上具有多个 AppMeasurement 对象的问题

v3.0(2018 年 4 月 13 日)

  • 修正版本(重新编译,代码更小)
  • 此插件现在可创建要分配给 Adobe Analytics 变量而不是返回值的变量
上一页getPageName
下一页getPreviousValue

Analytics