• Resolved johnwandler

    (@johnwandler)


    Hey, i’ve seen your “tutorial” about setting up a Google code in “Tracking form submission”, yet it’s not working.

    I’m debugging my code to track form submission with values. CF7 works perfectly fine, but after sending a form using WP Booking Calendar, there’s not a single event in GTM that specify submitting a form, only “Enter/Leave” input values, etc.

    Is there a way to track that? And by that i mean form submission with values.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wpdevelop

    (@wpdevelop)

    Hello.

    Did you check this article https://wpbookingcalendar.com/faq/tracking-form-submission/ If yes, then unfortunately, in the updates 9.8 or newer, that code is deprecated, as it mentioned in the FAQ article.

    Currently Booking Calendar generate this action hook:

    do_action( 'wpbc_track_new_booking', $params );

    So you can use this function:

    function my_booking_tracking( $params ){
    ...
    }
    add_action( 'wpbc_track_new_booking', 'my_booking_tracking' );

    But it’s works only for the back-end, not for the front-end with execution of the JavaScript. We will add improvements to this feature to the TODO list for having it in future updates of the plugin, but I can not say when this feature will be implemented. Sorry.

    Kind Regards.

    Thread Starter johnwandler

    (@johnwandler)

    Thank you for response.

    As i said – yes, i’ve checked that article before, but it doesn’t seems to work. I’m using 9.1.1 version. Do i have to type specific variables? GTM inside that function returns nothing on GTM page.

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    1) I will add to the TODO list to implement tracking possibility at front-end side and update the article. Currently that hook from the FAQ works only for back-end side tracking.

    2) In the next update 10.1 of Booking Calendar you can use this JavaScript hook ‘wpbc_booking_created‘ to trigger creation of the new bookings.

    To catch this event you will be able to use this code:

    jQuery( 'body' ).on( 'wpbc_booking_created', function( event, resource_id, params ) {
    ...
    } );

    Kind Regards.

    Thread Starter johnwandler

    (@johnwandler)

    Cool, but again – i’m using 9.1.1, not 10.X.

    Meanwhile, here you go, folks:

    function my_booking_tracking() { ?>
        <script type="text/javascript">
            window.dataLayer = window.dataLayer || [];
            const customEventName = // you can check for some fields etc. if you want to display custom event name in your GTM based on hidden/displayed fields, you can omit that, it'll be displayed as "Message" tab in your GTM
            window.dataLayer.push({
                'event': customEventName, // check above
                'inputs': document.querySelector('#name1').value
    
    // etc, etc, etc
            });
        </script>
    <?php }
    add_action('wpbc_track_new_booking', 'my_booking_tracking');

    Resolved myself. Please, read carefully next time what info client is giving you instead of typing responses from your template.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Form submission event missing in GTM’ is closed to new replies.