• I am running Facebook ad to get mailing list sign ups. I am using the following code to track conversion. However, my contact form is also using Contact Form 7. That makes my Facebook ads reporting for mailing list sign ups not accurate. How can I solve this?

    I need the eventlistener to not fire if the form is the contact form. I only have 3 contact forms site wide but the mailing list sign up appears in a lot of places, especially the footer.

    <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        fbq('track', 'Lead');
    }, false );
    </script>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    See https://contactform7.com/dom-events/

    You can set a narrower event target.

    Thread Starter alexloganlee

    (@alexloganlee)

    Hi Takayuki,

    I’ve actually read the page before starting this post.

    I tried changing the querySelector to a form id but it doesn’t seem to fire.

    var wpcf7Elm = document.querySelector( '#wpcf7-f5976-p24-o2' );
     
    wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
        alert( "Fire!" );
    }, false );

    And it’s not quite possible for me to target all form ids. I have the 5976 form in the footer of every page.

    • wpcf7-f5976-p24-o2
    • wpcf7-f5976-p878-o1
    • wpcf7-f3026-p24-o1

    Is it possible to target just the contact form 7 id? It would be great if you can provide me with an example and I can edit from there. I am not really sure how isolate the id for what I am trying to achieve. Thanks!

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Can I see the site?

    Thread Starter alexloganlee

    (@alexloganlee)

    Hi Takayuki,

    There are 2 type of forms I am using for my website, contact form and sign up form.
    The landing page for my campaign is: http://basicmodels.com.sg/be-a-model
    It contains 2 sign up forms, 1 on top and another in the footer.

    I would like to implement site wide tracking for my campaign. The contact form on the homepage and contact us page will affect the tracking as it uses the same DOM as the sign up form. The sign up form in the footer is site wide.

    Homepage: http://basicmodels.com.sg
    Contact us: http://basicmodels.com.sg/contact-us

    Thanks,
    Alex

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Then place the sign up form inside <div class="signupform"> </div> and give '.signupform' as the querySelector() parameter.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Tracking Different Forms’ is closed to new replies.