formId and formFields variable for amp-form-submit-success events
What's the issue?
amp-form-submit generates formId and formFields variables but not amp-form-submit-success nor amp-form-submit-error
Related to #11563
How do we reproduce the issue?
This works but it will create an event even if the submission fails
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"triggers": {
"productBuy": {
"on": "amp-form-submit",
"request": "event",
"vars": {
"eventCategory": "funnel tracking",
"eventAction": "buy ${formFields[productName]}"
}
}
},
"vars": {
...
}
}
</script>
</amp-analytics
This will create an event only if the submission is successful, but without the product name
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"triggers": {
"productBuy": {
"on": "amp-form-submit-success",
"request": "event",
"vars": {
"eventCategory": "funnel tracking",
"eventAction": "buy ${formFields[productName]}"
}
}
},
"vars": {
...
}
}
</script>
</amp-analytics
Which AMP version is affected?
Version 1522422854768
http://www.sdamsdam102030.com
c684681898d7
/to @cvializ
14435
Looks like this isn't implemented unfortunately. I'll open this as a feature request since I do see analytics data documented for the amp-form-submit event, but not for success and error.
The amp-form-submit event fires when a form request is initiated. The amp-form-submit event generates a set of variables that correspond to the specific form and the fields in the form. These variables can be used for analytics.
https://www.ampproject.org/docs/reference/components/amp-form#analytics-triggers
I've had a look at the code, and I think I might be able to propose something. Can I do a PR?
Now that the PR is merged, the change will go through our canary process. You should see it in production in about two weeks.