Request Trustpilot Invite
Enter the customer email. This will trigger the Trustpilot invite flow and send the review request.
const form = document.getElementById('inviteForm');
const statusEl = document.getElementById('status');
form.addEventListener('submit', async function (event) {
event.preventDefault();
const email = document.getElementById('email').value.trim();
if (!email) {
showStatus('Please enter a valid email.', 'error');
return;
}
showStatus('Sending invite...', '');
try {
const res = await fetch('send.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email })
});
const result = await res.json();
if (!res.ok || !result.success) {
throw new Error(result.message || 'Invite failed.');
}
showStatus('Invite sent successfully.', 'success');
if (window.tp) {
try {
window.tp('create', 'invite', {
email: email,
locale: 'en-US',
source: 'custom'
});
} catch (err) {
console.log('Trustpilot invite trigger fallback:', err);
}
}
form.reset();
} catch (error) {
showStatus(error.message || 'Something went wrong.', 'error');
}
});
function showStatus(message, type) {
statusEl.textContent = message;
statusEl.className = 'status';
if (type) statusEl.classList.add(type);
}