Add Google tracking code to submit button

By: Mark Robson | Asked: 08/16/2022
ForumsCategory: Code HelpAdd Google tracking code to submit button
Mark Robson asked 2 years ago

Just been sent tracking code from Google Ads agency and need to add code to submit button. Need help
Info sent:

Add an onclick attribute directly to the code for the button or link that you'd like to track. The code that you use will depend on how the link or button is displayed on your site: as a text link, button or button image.
Add the code to a button: This code shows you how to add click tracking functionality to a button using the <button> tag. Replace 'https://example.com/your-link' with the URL for your website.
<button onclick="return gtag_report_conversion('https://example.com/your-link')">Submit</button>
Looked in Form > Settings > Customise HTML > Submit Button and code in place shows as below, and couldn't figure out how or where to add OnClick cod. Any help appreciated
<div class="frm_submit">
[if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
<button class="frm_button_submit" type="submit" [button_action]>[button_label]</button>
[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]
</div>
 

2 Answers
Best Answer
Victor Font answered 2 years ago
Update the Submit button HTML in the form's Customize HTML screen. Change this code to: button class="frm_button_submit" type="submit" [button_action] onclick="return gtag_report_conversion('https://example.com/your-link')">[button_label]
Mark Robson replied 2 years ago

Thanks @Victor Font will give that a go.

Bobby Clapp answered 2 years ago

Based on what you are providing, this is what I suggest:

[button_label]

in formidable with this:

[button_label]

Mark Robson replied 2 years ago

Hi @Bobby Clapp Thanks for comment. I might be misunderstanding.

Replace [button_label] with [button_label]

?? isn't that replacing like with like?

Sorry of I have read incorrectly.

Bobby Clapp replied 2 years ago

It's not taking my code in the reply. Please wait until I get it fixed.

Mark Robson replied 2 years ago

Thx

Bobby Clapp replied 2 years ago

Victor plugged in what he could as I was trying to suggest.

Mark Robson replied 2 years ago

Thx @Bobby Clapp

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right