【问题标题】:Combine amp-analytics for amp-next-page为 amp-next-page 组合 amp-analytics
【发布时间】:2020-11-25 08:57:01
【问题描述】:

我目前正在使用以下代码在 WordPress 网站上跟踪我的 AMP 加速页面的浏览量:

    {
    "vars": {
        "account": "UA-12345678-1"
    },
    "triggers": {
        "trackPageview": {
            "on": "visible",
            "request": "pageview"
        }
    }
}

我刚刚在单个页面上实现了无限滚动,我还需要在滚动或单击时跟踪下一页。我在官方“amp.dev”页面上找到了以下代码:

 <amp-analytics>
  <script type="application/json">
    {
      "requests": {
        "nextpage": "https://example.com/pixel?RANDOM&toURL=${toURL}"
      },
      "triggers": {
        "trackScrollThrough": {
          "on": "amp-next-page-scroll",
          "request": "nextpage"
        },
        "trackClickThrough": {
          "on": "amp-next-page-click",
          "request": "nextpage"
        }
      }
    }
  </script>
</amp-analytics>

如何将这两个代码合并为一个,以便它可以跟踪网页浏览量和无限滚动(点击和滚动)

【问题讨论】:

    标签: wordpress google-analytics analytics amp-html


    【解决方案1】:

    我设法找到了解决方法,我在页脚中添加了以下代码并且它可以工作:

    <amp-analytics id="11e2c333333a" type="googleanalytics">
      <script type="application/json">
        {
          "requests": {
            "nextpage": "<?php get_permalink(get_the_ID()); ?>?amp"
          },
        "vars": {
            "account": "UA-12345678-1"
        },
          "triggers": {
            "trackScrollThrough": {
              "on": "amp-next-page-scroll",
              "request": "nextpage"
            },
            "trackClickThrough": {
              "on": "amp-next-page-click",
              "request": "nextpage"
            },
        "trackPageview": {
                "on": "visible",
                "request": "pageview"
            }
          }
        }
      </script>
    </amp-analytics>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-17
      • 1970-01-01
      相关资源
      最近更新 更多