Google Analytics点击通话事件到AMP

时间:2019-02-14 11:54:18

标签: google-analytics amp-html

我正在使用纯模式

如何将下面的代码更改为AMP版本?

onclick="gtag('event','Click to call',{'event_category':'Call tracking','event_label':'Mobile header'});"

1 个答案:

答案 0 :(得分:0)

  <script type="application/json">
    {
      "vars": {
        "gtag_id": "<GA_TRACKING_ID>",
        "config": {
          "<GA_TRACKING_ID>": {}
        }
      },
      "triggers": {
        "button": {
          "selector": "#the-button",
          "on": "click",
          "vars": {
            "event_name": "login",
            "method": "Google",
            "event_category": "Call tracking",
            "event_label": "Mobile header"
          }
        }
      }
    }
  </script>

文档:https://developers.google.com/analytics/devguides/collection/amp-analytics/#complete_example