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

107
Views
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 answers
Answer question

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 Report
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!