feat(bf): fire the trial conversion behind the same consent gate

Adds the second Google Ads label to /odoo-black-friday/: the free-trial
form (#trialForm) now fires AW-18065522009/AtAPCIjjvrAdENn6p6ZD (action
7886320008 "Registrierung") when it is submitted.

Reuses the existing gate in static/ads-consent.js rather than a second
mechanism: the label is read from the page (data-ads-trial-send-to on
#adsConsent), so the script stays generic. The page hands the gate its
real submit function via window.o4pAds.trialConversion; the gate fires
the conversion and runs the submit from the event callback, with the same
700 ms hard timeout that runs it anyway. Nothing fires and no cookie is
set before consent (identical default-deny gate).

The buy conversion is untouched (comments only).
This commit is contained in:
webmaster committed 2026-11-02 09:23:14 +00:00
1 parent 6d486ad954
commit 7497fbf588
3 files changed
+88 -28

No files matched your search

+31 -19
View File
@@ -241,25 +241,37 @@
var location = trialLoc ? trialLoc.value : '';
if (!email) return;
var btn = trialForm.querySelector('.btn-brass');
btn.textContent = 'Sending...';
btn.disabled = true;
fetch('https://n8n.odoo4projects.com/webhook/ODOO4projects/trial', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(UTM.inject({ email: email, location: location }))
}).then(function () {
if (window.plausible) window.plausible('Trial');
trialForm.style.display = 'none';
document.getElementById('trialSuccess').classList.add('visible');
}).catch(function () {
btn.textContent = 'Send';
btn.disabled = false;
var errorMsg = document.createElement('div');
errorMsg.className = 'trial-error visible';
errorMsg.textContent = 'Something went wrong. Please try again.';
trialForm.appendChild(errorMsg);
setTimeout(function () { errorMsg.classList.remove('visible'); }, 3000);
});
function sendTrial() {
btn.textContent = 'Sending...';
btn.disabled = true;
fetch('https://n8n.odoo4projects.com/webhook/ODOO4projects/trial', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(UTM.inject({ email: email, location: location }))
}).then(function () {
if (window.plausible) window.plausible('Trial');
trialForm.style.display = 'none';
document.getElementById('trialSuccess').classList.add('visible');
}).catch(function () {
btn.textContent = 'Send';
btn.disabled = false;
var errorMsg = document.createElement('div');
errorMsg.className = 'trial-error visible';
errorMsg.textContent = 'Something went wrong. Please try again.';
trialForm.appendChild(errorMsg);
setTimeout(function () { errorMsg.classList.remove('visible'); }, 3000);
});
}
/* When the consent gate is present it fires the Google Ads trial conversion and runs
sendTrial from the tag's callback, with a hard timeout that runs it anyway — so a
blocked or slow tag can never swallow the trial. Without the gate, send directly. */
if (window.o4pAds && typeof window.o4pAds.trialConversion === 'function') {
window.o4pAds.trialConversion(sendTrial);
} else {
sendTrial();
}
});
}
})();