Title: Missing event
Last modified: July 5, 2023

---

# Missing event

 *  Resolved [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/)
 * This site contains the following script code (add ?ao_noptimize=1 to the URL 
   to see the unoptimised page):
 *     ```wp-block-code
       jQuery(function($) {
       	$(document).ready(function(){
       		$('#page-header a[href^="tel:"]').on('click', function() {
       			gtag('event', 'click_to_call_header', { 'event_category' : 'phone_call', 'event_label' : window.location.pathname });
       		});
       		$('#page-content a[href^="tel:"]').on('click', function() {
       			gtag('event', 'click_to_call_content', { 'event_category' : 'phone_call', 'event_label' : window.location.pathname });
       		});
       		$(document).on('wpcf7mailsent', function( event ) {
       			gtag('event', 'inquiry', { 'event_category' : 'form_submission', 'event_label' : $("#your-service").val() });
       			location = 'https://drroof.com.au/thank-you/?subject='+$("#your-service").val();
       		});
       	});
       });
       ```
   
 * In Google Analytics 4, I can see the “click_to_call_*” events, which means the
   code works OK, but when a form is submitted, I only get a “form_submit” event,
   not an “inquiry” event.
 * I use very similar code on other sites that integrate with MonsterInsights, and
   they all record “inquiry” events, but not this site, which uses CAOS and CAOS
   Pro without integration.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmissing-event-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16870858)
 * Hi Gal,
 * The inquiry event is attached to a custom JS event, called `wpcf7mailsent`. I
   download Contact Form 7, but I can’t find that event anywhere in the code.
 * Is that a custom code snippet, or from an add-on or something?
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16870893)
 * It’s a custom event created by CF7, but, like I said, this snippet works on other
   sites, and it works on this site for the other events.
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16871007)
 * Hi Gal,
 * Just ran a test with CAOS and CAOS Pro enabled and added your code:
 * ![](https://i0.wp.com/i.imgur.com/myh7Wkr.png?resize=369%2C489&ssl=1)
 * As you can see, the `inquiry` event is being triggered. Are you getting console
   errors?
 * Maybe you should try excluding the code from Autoptimize to avoid JS errors or
   execution failures.
 * If you share your settings in CAOS here, I can duplicate them and maybe then 
   I’ll be able to replicate the issue.
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16871039)
 * Allow tracking: always
 * Tracking code: asynchronous
 * Anonymize IP: one octet
 * Tracking code position: header
 * Cache directory: /cache/caos/
 * Stealth Mode: checked
 * The rest of the settings are blank or unchecked
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16871055)
 * Okay, so that’s how I tested it.
 * In your console, do you see the beacon being sent after submitting the contact
   form?
 * ![](https://i0.wp.com/i.imgur.com/Sy11XWO.png?ssl=1)
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16873372)
 * I don’t see a POST in the console. Unfortunately, the page reloads, so I might
   be missing something when the console clears.
 * But I do see a call to the stealth script in the network tab.
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16874176)
 * ahhh, the page reloads after submitting the form? Might be that the beacon doesn’t
   get executed before the redirect happens. What happens if you add a timeout to
   the script to wait 1 or 2 seconds before redirecting?
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16876530)
 * This seems like a good idea, but it wouldn’t be good for user experience, and
   apparently isn’t required for the `form_submit` event to trigger. Also, again,
   none of my other sites require this, and they all redirect or reload the page.
 * But, come to think of this, the event handler is supposed to take the user to
   another page, and this doesn’t happen, so CAOS seems to be in the clear. Sorry,
   should have thought of that.
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16876878)
 * It was a suggestion meant for debugging purposes. If it starts working then, 
   we know it’s the script, and not CAOS.
 * But CAOS seems to be in the clear either way. Happy hunting! 😉

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

The topic ‘Missing event’ is closed to new replies.

 * ![](https://ps.w.org/host-analyticsjs-local/assets/icon-256x256.png?rev=3307068)
 * [CAOS | Host Google Analytics Locally](https://wordpress.org/plugins/host-analyticsjs-local/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/host-analyticsjs-local/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/host-analyticsjs-local/)
 * [Active Topics](https://wordpress.org/support/plugin/host-analyticsjs-local/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/host-analyticsjs-local/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/host-analyticsjs-local/reviews/)

## Tags

 * [compatibility](https://wordpress.org/support/topic-tag/compatibility/)

 * 9 replies
 * 2 participants
 * Last reply from: [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/missing-event-2/#post-16876878)
 * Status: resolved