cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x]: URL passthrough rewrite failing when using actionInput

Open WHITE-developer opened this issue 1 year ago • 0 comments

What happened?

Description

Got this from: https://craftcms.stackexchange.com/questions/41657/url-passthrough-rewrite-failing-when-using-actioninput

We are experiencing some issues with form submissions on websites that are using action inputs.

If a visitor denies analytics_storage via a cookie consent plug-in. Google Tagmanager will start using the URL passthrough function to pass the GCLID and other data otherwise stored in cookies by rewriting all URL's on a page.

This rewriting also happens on form submissions and will try to change the "action" attribute on the submitted form. To do this, the Google JavaScript tries to read the action parameter of the form and that's where things go wrong. Reading the action attribute of a form that's using the actionInput tag returns the complete HTMLInputElement instead of the action string. And Google appends that complete object to the rewritten action attribute. Resulting in a form that's submitted to: "/[Object HTMLInputElement]?GOOGLE_STRING". Which obviously doesn't work.

Contacting Google about this issue seems like a pretty lost cause. But is there any way to solve this in our website or Google Tagmanager settings without disabling the URL passthrough?

Steps to reproduce

  1. Click from a google ad to the site
  2. Errors when adding to cart, accept cookies and other form submission

Craft CMS version

4

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

WHITE-developer avatar May 21 '24 10:05 WHITE-developer