I am integrating Trustpilot invitations into my receipt page using the following code provided by Trustpilot
<script>
document.addEventListener('DOMContentLoaded', function() {
const trustpilot_invitation = {
recipientEmail: 'john@gmail.com',
recipientName: 'John',
referenceId: 'Order_123',
source: 'InvitationScript',
};
tp('createInvitation', trustpilot_invitation);
});
The email and name strings I will use contain spurious characters which I need to cleanse, using something like
var email = '<Actinic:Variable Name="InvoiceEmail"/>';
email = email.replace('Email: ','');
How do I pass the cleansed strings back to the Trustpilot script?
The 'john@gmail.com'
string in your above snippet can be replaced with whatever you want, be it a function call that returns a string, or just a string variable.
eg:
var badEmail = '<Actinic:Variable Name="InvoiceEmail"/>'
document.addEventListener('DOMContentLoaded', function() {
const trustpilot_invitation = {
recipientEmail: badEmail.replace('Email: ',''),
recipientName: 'John',
referenceId: 'Order_123',
source: 'InvitationScript',
};
tp('createInvitation', trustpilot_invitation);
});