我试图在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>
答案 0 :(得分:1)
vars
传递。例如。对于Google Analytics(分析),分别为event_label
,event_name
和event_category
。有关AMP & GA integration here的更多信息。…
"formSubmit": {
"on": "amp-form-submit-success",
"selector": "form",
"request": "event",
"vars": {
"event_label": "Label 1"
}
},
…