trackClickOnHeader AMP分析事件未被触发

时间:2017-06-12 17:29:17

标签: html analytics amp-html

我正在尝试在点击链接时触发“trackClickOnHeader”的AMP分析事件。这是一个示例文件

<!doctype html>
<html amp lang="en" >
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>


  <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
  <script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>

  <script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
  <link rel="canonical" href="https://ampbyexample.com/components/amp-analytics/">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  <style amp-custom>
    .fixed-dashboard {
        background-color: #e0e0e0;
        position:fixed;
        bottom: 0;
        right: 0;
        width:100%;
        z-index: 100;
    }
    amp-carousel .slide {
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      background: green;
      color: white;
    }
    #clkwallpaper3{}
    #clkwallpaper{}
    #clkpocketdownload{  }
    #clkbenifits{ }
    #clkprocedure{ }
    #clkwallpaper1{ }
    #clkwallpaper{ }

    </style>
<body>
<!-- AMP Analytics -->
<amp-analytics type="googleanalytics">
<script type="application/json">
{
  "vars": {
    "account": "UA-XXXXXX-1"
  },
  "triggers": {
    "trackPageview": {
      "on": "visible",
      "request": "pageview"
    },
    "trackClickOnHeader" : {
      "on": "click",
      "selector": "#clkpocketdownload",
      "request": "event",
      "vars": {
        "eventCategory": "Pocketpdf",
        "eventAction": "header-click"
      }
    },
    "trackClickOnHeader" : {
      "on": "click",
      "selector": "#clkbenifits",
      "request": "event",
      "vars": {
        "eventCategory": "Benifits",
        "eventAction": "header-click"
      }
    }

	  }
}
</script>
</amp-analytics>
<!--  AMP Analytics --->

<ul>
  <li>
    <a id="clkpocketdownload"> a special link</a>.</li>
  <li>
    <a id="clkwallpaper1">a not so special link</a>.</li>
  <li>
    <a id="clkwallpaper">a not so special link</a>.</li>
  <li>
    <a id="clkbenifits">a not so special link</a>.</li>
  <li>
    <a id="clkprocedure">a not so special link</a>.</li>

</ul>
</body>
</html>

当选择器clkbenifits触发事件时,它从未触发clkpocketdownload。当我在触发器列表中更改其位置时,clkpocketdownload会停止触发。 1.推荐的组合多个触发事件的方法是什么? 2.他们是通过chrome调试器界面调试AMP分析事件的方法吗?

谢谢

1 个答案:

答案 0 :(得分:0)

标题&#34; trackClickOnHeader&#34;正在使用其他类似的标题。 因此,一旦我为每个事件更改为唯一名称,它就会按预期开始工作。