Pre populate text in Newsletter Block

To pre poplulate text in Newsletter Block when users url like this: /newsletter?fname=Nick&lname=Hutton&[email protected]

You can use this code to Code Injection > Footer.

<script>
document.addEventListener('DOMContentLoaded', function() {
    const urlParams = new URLSearchParams(window.location.search);
    
    const fname = urlParams.get('fname');
    const lname = urlParams.get('lname'); 
    const email = urlParams.get('email');
    
    const firstNameField = document.querySelector('input[name="fname"]');
    const lastNameField = document.querySelector('input[name="lname"]');
    const emailField = document.querySelector('input[name="email"]');
    
    if (fname && firstNameField) {
        firstNameField.value = fname;
    }
    
    if (lname && lastNameField) {
        lastNameField.value = lname;
    }
    
    if (email && emailField) {
        emailField.value = email;
    }
});
</script>

Buy me a coffee