Issues with the module route. The second option does not work; only the first one works

:bullseye: What is your goal?

To pass the second option in a module route, since I am using Google Sheets.

document.addEventListener(‘DOMContentLoaded’, function() {
const webhookUrl = ‘https://hook.us2.make.com/mhjj…’;

// Funct
async function track(eventLabel, targetUrl, isExternal) {
    console.log("Try:", eventLabel);
    const data = {
        evento: eventLabel,
        timestamp: new Date().toISOString(),
        pageUrl: window.location.href,
        fbclid: new URLSearchParams(window.location.search).get('fbclid') || "no_fbclid"
    };

    // Send asinc
    fetch(webhookUrl, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(data),
        keepalive: true
    }).catch(err => console.error("Error:", err));

    // Redirec
    if (isExternal) {
        window.open(targetUrl, '_blank');
    } else {
        window.location.href = targetUrl;
    }
}

// Listener 
const btnDonar = document.getElementById('btn-donar');
if (btnDonar) {
    btnDonar.addEventListener('click', function(e) {
        e.preventDefault();
        track('click_donacion', 'https://www.g....ndme.com......', true);
    });
} else {
    console.error("Not found btn-donar");
}

// Listener WhatsApp
const btnWhatsApp = document.getElementById('btn-whatsapp');
if (btnWhatsApp) {
    btnWhatsApp.addEventListener('click', function(e) {
        e.preventDefault();
        track('click_whatsapp', btnWhatsApp.href, true);
    });
} else {
    console.error("Not found btn-whatsapp");
}

});

Could someone help me, please? Thanks.

:thinking: What is the problem & what have you tried?

In Make, I used the Router module for two paths. The first path works, but the second one does not. Here is the logic: on a landing page, I have two buttons that open a blank window to another site. One redirects to an external page, and the other to WhatsApp. The purpose of the webhook is to handle the scenario where a user wants to view the content (Path 1) but has a question, so they return to the landing page to click the WhatsApp button.

:clipboard: Error messages or input/output bundles

document.addEventListener(‘DOMContentLoaded’, function() {
const webhookUrl = ‘https://hook.us2.make.com/mhjj164fpuhqglijbwnhuuap8rjkmved’;

// Función unificada
async function track(eventLabel, targetUrl, isExternal) {
    console.log("Intentando rastrear:", eventLabel);
    const data = {
        evento: eventLabel,
        timestamp: new Date().toISOString(),
        pageUrl: window.location.href,
        fbclid: new URLSearchParams(window.location.search).get('fbclid') || "no_fbclid"
    };

    // Enviamos el dato asíncronamente
    fetch(webhookUrl, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(data),
        keepalive: true
    }).catch(err => console.error("Error en el envío:", err));

    // Redirección
    if (isExternal) {
        window.open(targetUrl, '_blank');
    } else {
        window.location.href = targetUrl;
    }
}

// Listener para Donar (Se cambió el último parámetro a 'true' para abrir en nueva pestaña)
const btnDonar = document.getElementById('btn-donar-remesa');
if (btnDonar) {
    btnDonar.addEventListener('click', function(e) {
        e.preventDefault();
        track('click_donacion', 'https://www.gofundme.com/f/la-remesa-tu-esfuerzo-completo-saldras-adelante', true);
    });
} else {
    console.error("NO SE ENCONTRÓ EL BOTÓN btn-donar-remesa");
}

// Listener para WhatsApp
const btnWhatsApp = document.getElementById('btn-whatsapp-remesa');
if (btnWhatsApp) {
    btnWhatsApp.addEventListener('click', function(e) {
        e.preventDefault();
        track('click_whatsapp', btnWhatsApp.href, true);
    });
} else {
    console.error("NO SE ENCONTRÓ EL BOTÓN btn-whatsapp-remesa");
}

});

:link: Create public scenario page