Event Tracking Doesn’t Work on iPhones
-
I have the following installed on each page in order to track contact form submissions using Analytics:
<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-xxxxxxxx-1', 'auto'); ga('send', 'pageview'); </script>
Below that, I have the event tracking for successfully sending:
<script> document.addEventListener( 'wpcf7mailsent', function( event ) { ga( 'send', 'event', 'Contact Form', 'submit', event.detail.id.toString()); }, false ); </script>
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?
- The topic ‘Event Tracking Doesn’t Work on iPhones’ is closed to new replies.