Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Consent Mode changes form action on submit to include [object%20HTMLInputElement]?gl=123 #2159

Open
joepagan opened this issue Nov 25, 2024 · 3 comments

Comments

@joepagan
Copy link

Describe the bug

On one of our apps which uses formie, when a user has only opted for necessary cookies and later submits a form they will be redirected to a url like this (even when ajax submission is on the formie form).

I notice the action changes on the submit event.

This looks to be intention as a way for Google to send a cookieless ping to google however as a concequence it redirects the user to the action:

domain.com/[object%20HTMLInputElement]?_gl=1*1trac45*_up*MQ..*_ga*NDE0NTIzMDMwLjE3MzI1NzAzMDg.*_ga_VGE67CL4VC*MTczMjU3MDMwOC4xLjEuMTczMjU3MDMxNC4wLjAuMA..

It looks like Brandon has come up with a suggestion:
https://craftcms.stackexchange.com/questions/41657/url-passthrough-rewrite-failing-when-using-actioninput

Looks like other devs have reported the same issue to Google who will of course never respond:
https://support.google.com/tagmanager/thread/269636163/form-action-fields-changes-when-form-is-submitted-after-applying-consent-mode-v2?hl=en

However, I wonder if it's possible for the formie JS to somehow detect an action on a form element and prevent a redirect onwards, especially if the form is in ajax submission mode?

FYI - it does look like the submission data is stored, however they appear to have been labelled as spam in the backend.

Steps to reproduce

  1. have consent mode v2
  2. opt out of non-essential cookies
  3. submit formie form
  4. get redirect to page url like /[object%20HTMLInputElement]?_gl=x

Form settings

  • Multi-page form: Yes or No
  • Submission Method: Ajax or Page Reload
  • Client-side Validation: Yes or No
  • Custom Form Templates: Yes or No

Craft CMS version

5

Plugin version

3

Multi-site?

yes

Additional context

No response

@engram-design
Copy link
Member

Very interesting, first I've heard about this!

If it helps, the same workaround can work in Formie with Theme Config:

{{ craft.formie.renderForm(form, {
    themeConfig: {
        form: {
            attributes: {
                action: craft.app.request.absoluteUrl,
            },
        },
    },
}) }}

@joepagan
Copy link
Author

Hey @engram-design yes I did try exactly this suggestion, however despite being on an ajax formie form, submitting with a custom action will cause a redirect to the action URL rather than preventing it and showing the success message.

@engram-design
Copy link
Member

@joepagan Just tested that with an Ajax form, and that's working as expected to me, sorry to say. It's not redirecting to the actionUrl. There's no JS errors when submitting the form?

Here's how we handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants