Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
How can I enable google analytics tracking on Contact Form 7 when I have one or more checked checkbuttons?

My contact form has this Format:

<div class="col-md-12">[text* text-813 placeholder "Name:"]</div>
<div class="col-md-12">[email* email-597 placeholder "EMail:"]</div>
<div class="col-md-12">[tel* tel-345 placeholder "Tel:"]</div>
</p>
[checkbox checkbox-770 id:Personal use_label_element "Personal"]
[checkbox checkbox-771 id:Buisness use_label_element "My Buisness"]
</div>
[textarea textarea-552 placeholder "Ask about anything!"]</div>
[submit "Submit"]</div>

And I want to enable GA tracking for their respective fields when one or more of the checkbox inputs are checked.

Here is the code I have tried so far:

document.addEventListener( 'wpcf7submit', function( event ) {
    jQuery(function($) {
        if ($('input').is(':checked')) {
            dataLayer.push({
            'event': 'Form_Submission' 
            'Interest': 'Business'
            });
        } 

        if ($('input').is(':checked')) {
            dataLayer.push({
            'event': 'Form_Submission' 
            'Interest': 'Personal'
            });
        }
    });

}, false );

But it doesn't work, I get no errors as a result. Can anyone help me figure this out? Thanks in Advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to use the event.detail.inputs that is passed by wpcf7submit

document.addEventListener( 'wpcf7submit', function( event ) {
    let inputs = event.detail.inputs;
    for ( let i = 0; i < inputs.length; i++ ) {
        if ( 'checkbox-770[]' == inputs[i].name ) {
            dataLayer.push({
                'event': 'Form_Submission',
                'Interest': 'Personal'
            });
        } else if ('checkbox-771[]' === inputs[i].name ){
            dataLayer.push({
                'event': 'Form_Submission',
                'Interest': 'Business'
            });
        }
    }
}, false );
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda