I’m looking for visitors to click a button that has a prepopulated email address, subject, and body copy. Currently when I use the email click action in a button I can only prepopulate the email address and subject. Has anyone found a javascript that would do this and knows how to attach the buttons ID to it?
Page 1 / 1
Hi
Something like this might do the trick:
<script>
document.addEventListener('DOMContentLoaded', (event) => {
var emailButton = document.querySelector('.emailButton');
emailButton.addEventListener('click', function(e) {
e.preventDefault();
var mailtoLink = 'mailto:hello@hello.com?subject=Your Subject Here&body=Your pre-filled email content goes here.';
window.location.href = mailtoLink;
});
});
</script>
Just a few notes:
- Be careful with the body you pre-fill since different email clients handle these differently. Some email clients don’t like too long mailto links.
- As always… make sure you test this out before deploying to your pages
- Last but not least… make sure you add a class to your buttons “emailButton”
Reply
Log in to the Unbounce Community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.