• Resolved Gal Baras

    (@galbaras)


    This site contains the following script code (add ?ao_noptimize=1 to the URL to see the unoptimised page):

    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 to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    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

    (@galbaras)

    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 DaanvandenBergh

    (@daanvandenbergh)

    Hi Gal,

    Just ran a test with CAOS and CAOS Pro enabled and added your code:

    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

    (@galbaras)

    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 DaanvandenBergh

    (@daanvandenbergh)

    Okay, so that’s how I tested it.

    In your console, do you see the beacon being sent after submitting the contact form?

    Thread Starter Gal Baras

    (@galbaras)

    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 DaanvandenBergh

    (@daanvandenbergh)

    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

    (@galbaras)

    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 DaanvandenBergh

    (@daanvandenbergh)

    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.