amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

formId and formFields variable for amp-form-submit-success events

Open nbonnotte opened this issue 8 years ago • 7 comments

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

nbonnotte avatar Apr 05 '18 11:04 nbonnotte

http://www.sdamsdam102030.com

sdamsdam102030 avatar Apr 05 '18 18:04 sdamsdam102030

c684681898d7

sdamsdam102030 avatar Apr 05 '18 18:04 sdamsdam102030

/to @cvializ

newmuis avatar Apr 05 '18 20:04 newmuis

14435

sdamsdam102030 avatar Apr 05 '18 21:04 sdamsdam102030

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

cvializ avatar Apr 05 '18 22:04 cvializ

I've had a look at the code, and I think I might be able to propose something. Can I do a PR?

nbonnotte avatar Jun 10 '18 16:06 nbonnotte

Now that the PR is merged, the change will go through our canary process. You should see it in production in about two weeks.

cvializ avatar Jun 20 '18 19:06 cvializ