Support » Plugin: Contact Form 7 » Event Tracking Doesn’t Work on iPhones

  • I have the following installed on each page in order to track contact form submissions using Analytics:

      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      ga('create', 'UA-xxxxxxxx-1', 'auto');
      ga('send', 'pageview');

    Below that, I have the event tracking for successfully sending:

    document.addEventListener( 'wpcf7mailsent', function( event ) {
        ga( 'send', 'event', 'Contact Form', 'submit',;
    }, false );

    This works flawlessly on desktop (no console errors). Upon submission, the success message pops up under the form and I see a clear conversion in Analytics. Simulating an iPhone works just the same using Chrome’s dev tools.

    We tested this on an Android phone (Samsung) and the form worked as designed.

    However, if I test the form on an actual iPhone 6+, iOS 9.3.3 (used both Safari and Dolphin to test) the page redirects to the same page and adds something like #wpcf7-f4-o1 to the end. The success bar still shows below the form, but it is NOT an AJAX event. Any submissions done this way on a phone are NOT picked up by Analytics, even though nothing else has changed. No console errors. Cache is cleared. Can you do a test and see if you run into the same issue?

    • This topic was modified 4 years, 7 months ago by Davy.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Takayuki Miyoshi


    It is because the wpcf7mailsent DOM event runs only in AJAX-mode submissions.

    Thread Starter Davy


    Ok. Why is an iPhone not triggering AJAX and instead redirecting to a new page upon submission, then? Is this a bug or is the form not able to run AJAX on an iPhone?

    Like I said, this runs fine on Android and desktop. iPhones are the only ones I have found that refuse to submit the form without reloading the page.

    In the case of iPhones not being supported for the DOM events, is there an alternative way to listen for a successful submission on the form so I can cover all bases? I took a look at this page, but it looks like the other method I would think to use (on_sent_ok) is depreciated and wouldn’t be a good idea:

    Plugin Author Takayuki Miyoshi


    AJAX submission doesn’t work on some old browsers, and Contact Form 7 provides non-AJAX (plain HTTP POST) submission as a fallback for such old environment. The on_sent_ok method also doesn’t work in this case because it runs on AJAX responses.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Event Tracking Doesn’t Work on iPhones’ is closed to new replies.