Bienvenido, Invitado
Recordarme

TEMA:

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262389

  • Autor del tema
  • Breezrusr
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 19
  • Gracias recibidas: 0
Hi,

I'm trying to add this onclick attribute to the submit button of a form:

onclick="return gtag_report_conversion(' example.com/your-link ')"

I tried 2 different methods but they all create bugs in the form:

METHOD 1: Creating custom Submit button (as indicated in this thread bit.ly/3yCeUS5 )
Bug: The onclick attribute is not being added and the form is not being submitted.
Code:
function ff_SUBMITCUSTOM_action(element, action)
{
switch (action) {
case 'click':
onclick="return gtag_report_conversion(' example.com/your-link ')"
break;
default:;
} // switch
} // ff_SUBMITCUSTOM_action
ff_validate_submit();

METHOD 2: Adding a custom initialization script ( bit.ly/3lQFkMt )
BUG: The form is being submitted but not being validated and nothing is being sent to the mailback email or being received in the admin email
CODE:
function ff_FreeAuditRequest_breezy_EN_init()
{
jQuery('#bfSubmitButton').attr('onclick', "gtag_report_conversion(' example.com/your-link ');" + jQuery('#bfSubmitButton').attr('onclick'));

} // ff_FreeAuditRequest_breezy_EN_init

Of course instead of example.com/your-link i put my link. This is just to show the code example.

Any suggestions on what might be going on?

Thanks.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Breezrusr.

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262398

  • Avatar de Mirec
  • Mirec
  • Ausente
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 1378
  • Karma: 2
  • Gracias recibidas: 76
Hi,

Go to your forms advanced properties > Scripts > Initialization script, click Custom and click Create code framework. Inside the created function (between the curly brackets { }), add the following:
jQuery('#bfSubmitButton').attr('onclick',  'gtag_report_conversion("example.com/your-link");' + jQuery('#bfSubmitButton').attr('onclick')); 

Let me know the Result!

Regards,
Mirko

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262421

  • Autor del tema
  • Breezrusr
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 19
  • Gracias recibidas: 0
I tried your suggestion and here are the bugs I encountered:

1. If I leave some required fields empty the "Please fill in the required fields" message is being displayed and when I close the message the form is being submitted without letting me fill the required fields first.

2. The double quotes between the url ("example.com/your-link") get transform into html entities (& quote ; example.com/your-link & quote ; ) but I was able to fix that bug by replacing the double quotes with single and the first single quotes with double quotes like so:

jQuery('#bfSubmitButton').attr('onclick', "gtag_report_conversion('example.com/your-link');" + jQuery('#bfSubmitButton').attr('onclick'));

3. Also if I add the return keyword to insert the exact code google is asking to add, like so:

jQuery('#bfSubmitButton').attr('onclick', "return gtag_report_conversion('example.com/your-link');" + jQuery('#bfSubmitButton').attr('onclick'));

the form is being sent without sending any auto-responder/admin emails nor validating any fields.

Other than that the form works perfectly without the google code added to the onclick attribute.

Any other suggestions?

Thanks.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Breezrusr.

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262422

  • Avatar de Mirec
  • Mirec
  • Ausente
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 1378
  • Karma: 2
  • Gracias recibidas: 76
Hi,

ok, I will see what I can do with this and back to you as soon as possible.

Regards,
Mirko

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262424

  • Autor del tema
  • Breezrusr
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 19
  • Gracias recibidas: 0
Ok. Thanks. I need to deliver this asap so your help is greatly appreciated.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Adding Google tag manager onclick attribute to Submit button 3 meses 3 semanas antes #262442

  • Avatar de Mirec
  • Mirec
  • Ausente
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 1378
  • Karma: 2
  • Gracias recibidas: 76
Hi,

3. Also if I add the return keyword to insert the exact code google is asking to add, like so:


did you try to send the Form with out RETURN keyword?


Regards,
Mirko

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
  • 2
  • 3
Moderadores: ForumSupport
Tiempo de carga de la página: 0.050 segundos