Custom Code: onclick ga (Google conversion tracking) disables form data submission. Help?

Hi peeps!

Hopefully someone can help me with this issue of mine. It revolves around custom code and a form submit button:

I have created a landing page. On the page’s form, I have created the submit button entirely with custom code. It works when sending a message through the form; all information is submitted correctly. Here is the code I used for said submit button:

input type=“submit” value=“Nachricht senden” data-wait=“Wird gesendet…” class=“btn-blue w-button” (the < and > arrows are correctly placed. But the Webflow forum doesn’t show correctly if I leave them there).

Now, I want to add an onclick attribute inside this HTML embed that tracks conversions. This is the code I need to add:

onclick=“return gtag_report_conversion(‘https://goodnity-kpi.workspex.de’);”

So, when I add it, the final code looks like this:

input type=“submit” value=“Nachricht senden” data-wait=“Wird gesendet…” class=“btn-blue w-button” onclick=“return gtag_report_conversion(‘https://goodnity-kpi.workspex.de’);” (again, arrows < and > are correctly in place).

However, adding this onclick attribute destroys the form’s funcionality! The redirect works, but no form data is sent. Neither to my email, nor is the data shown on the project settings console (so, submission count does not go up either).

Any idea what I am doing wrong? How can I make this onclick conversion tracking work?

Thank you in advance!

Kevin Brand

P.D. My read-only link is here: https://preview.webflow.com/preview/goodnity-suite?utm_source=goodnity-suite&preview=9f5d40b22e7180d89ea3cf0f58099c7a

However, I don’t think a preview link would help since this is a coding question. But just in case! Inside the preview-link, you will need to go to the navigator, open the “form-pop” symbol, and style it with display:flex. It is display:none right now so that it triggers as a pop-up.

You can use JQuery to trigger the event with a normal button. That should not interfere with your interaction or the form. No need for the embed html button. Since only one onclick handler can be assigned to an object at a time.

See this topic and look for the post by @cyberdave.

See if this resolves your issue.

Hi WebDev! Thank you for the reply. I am going to use that function from that other thread, hopefully it works.

If it doesn’t and I don’t get any other replies, I’ll simply create a “thank you” page and track visits to that page alone. But would love to find out how to make this work first lol

Cheers!