Removing GTM on pages with an RSVP form

We are looking into enabling RSVP but to be compliant we need to ensure GTM is removed on any pages that include a form.

Is there a way to determine whether a form exists and remove GTM? In our index.php we have GTM as its own widget, so I was kind of hoping I could just put a conditional format around that, however, when I tested the following script, it couldn’t find the form. So I’m wondering if the form generates after the page loads.

<!-- TESTING -->
<xphp content="true">
        <if has_element=".lw_payments_registration_form" />
            <!-- TEST: FOUND FORM! -->
        <else content="true">
                <!-- TEST: DID NOT FIND FORM! -->

If I change the class to use the parent “. event-body–registration” then it works, however, that is on every event, so it always returns true.

I’m combing through the documentation but so far I haven’t been able to figure out a way (or the right way) to do this. Any suggestions?

Hi Sejr,

Since the RSVP form loads dynamically after the event details page (which itself loads via AJAX), any XPHP like you have (which runs on 1st page load) can’t “know” that you’re going to navigate to an event details page.

Instead, I think what you want would be doable with JavaScript/jQuery. LiveWhale sends a $(‘body’).trigger(‘paymentFormLoad.lw’); when the RSVP form is loaded, so you could conceivably do something like this in your calendar-custom.js.

$('body').bind('paymentFormLoad.lw', function() {
    console.log('RSVP form loaded');
    // Use JS or jQuery to disable GTM for the remainder of the session?

Hope this helps!

1 Like