0

在 AMP 中提交成功后,我试图触发一个事件。

目前我使用 dataLayer.push() 并发送:类别、动作和标签。

如何使用本文档中的示例触发成功事件https://amp.dev/documentation/components/amp-form/#analytics-triggers

这是文档中的代码:

<amp-analytics>
  <script type="application/json">
    {
      "requests": {
        "event": "https://www.example.com/analytics/event?eid=${eventId}",
        "searchEvent": "https://www.example.com/analytics/search?formId=${formId}&query=${formFields[query]}"
      },
      "triggers": {
        "formSubmit": {
          "on": "amp-form-submit",
          "request": "searchEvent"
        },
        "formSubmitSuccess": {
          "on": "amp-form-submit-success",
          "request": "event",
          "vars": {
            "eventId": "form-submit-success"
          }
        },
        "formSubmitError": {
          "on": "amp-form-submit-error",
          "request": "event",
          "vars": {
            "eventId": "form-submit-error"
          }
        }
      }
    }
  </script>
</amp-analytics>
4

1 回答 1

1
  1. 缺少选择- AMP 必须知道这是哪个表单元素
  2. 附加数据可以作为vars. 例如,对于 Google Analytics,它是event_labelevent_nameevent_category。有关AMP 和 GA 集成的更多信息,请点击此处
…
"formSubmit": {
  "on": "amp-form-submit-success",
  "selector": "form",
  "request": "event",
  "vars": {
    "event_label": "Label 1"
  }
},
…
于 2020-03-18T17:50:07.987 回答