Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Form submit tracking

I'm trying to get Google Ads to track a conversion every time the user submits a form on a wordpress site. The problem is that even though everything is placed correctly I can't track the click even. The global Google tag is placed on the website, as well as the page specific tag and the button tag [Originally: return gtag_report_conversion('https://theurl.com/sub/')] which is where I think the issue lies. I'm utilizing the following code to modify the form's submit button in order to add the onclick event:

add_filter( 'gform_submit_button_3', 'form_submit_button', 10, 2 );
function form_submit_button( $button, $form ) {
    return '<input type="submit" id="gform_submit_button_3" class="gform_button button" value="Enviar" onclick="return gtag_report_conversion(https://theurl.com/sub/); if(window[&quot;gf_submitting_3&quot;]){return false;}  window[&quot;gf_submitting_3&quot;]=true; " onkeypress="if( event.keyCode == 13 ){ if(window[&quot;gf_submitting_3&quot;]){return false;} window[&quot;gf_submitting_3&quot;]=true;  jQuery(&quot;#gform_3&quot;).trigger(&quot;submit&quot;,[true]); }">';
}

As you can see I had to modify the code slightly to remove the apostrophes so it didn't screw up with the function and I think that may have something to do with the issue I'm having.

I also tried to escape part of the html code like this, but that completely disables the function of the button (the page reloads and nothing gets send):

add_filter( 'gform_submit_button_3', 'form_submit_button', 10, 2 );
function form_submit_button( $button, $form ) {
    $theurl = "return gtag_report_conversion('https://theurl.com/join/')";
    return '<input type="submit" id="gform_submit_button_3" class="gform_button button" value="Enviar" onclick="if(window[&quot;gf_submitting_3&quot;]){return false;}  window[&quot;gf_submitting_3&quot;]=true; '. esc_html($theurl) .';" onkeypress="if( event.keyCode == 13 ){ if(window[&quot;gf_submitting_3&quot;]){return false;} window[&quot;gf_submitting_3&quot;]=true;  jQuery(&quot;#gform_3&quot;).trigger(&quot;submit&quot;,[true]); }">';
}

Any clue what I could be doing wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!