How to correctly insert automatic redirection code in email sign up form?

Topic summary

Goal: Automatically redirect subscribers to a custom thank-you page after submitting the email sign-up form in a Shopify theme.

Proposed approach (from Shopify support):

  • Edit theme code (Online Store > Themes > Actions > Edit code) and find the form in sections/newsletter.liquid or sections/footer.liquid.
  • Insert a JavaScript snippet that listens for the form’s submit event and sets window.location.href to the thank-you page URL.
  • Customize by replacing ‘yourFormId’ with the actual form element’s HTML id, and ‘URL_of_Your_Thank_You_Page’ with the desired destination URL.

User request: Guidance on the exact placement of the script within the theme file and how to identify/use the correct form ID for their store’s newsletter form.

Context/attachments: A screenshot of the email sign-up form is provided. The storefront URL and a password were shared for access/testing.

Status: No resolution yet; user seeks specific implementation steps and confirmation of correct insertion and IDs.

Summarized with AI on January 5. AI used: gpt-5.

Hi,

I have been given a solution by shopify support and I’d like some help on how to insert the code.

The code enables customers to be automatically redirected once they fill in their email within the email sign up form.

Picture 1 shows the email sign up form.

This is the message i got from shopify support:

  1. Edit the Form Code:
    • Go to your Shopify admin dashboard and navigate to Online Store > Themes > Actions > Edit Code.
    • Locate the form file where the email sign-up form is present (e.g., sections/newsletter.liquid or sections/footer.liquid).
    • Add the following code snippet just after the form submission code:
<script>
document.getElementById('yourFormId').addEventListener('submit', function() {
  [window.location.href](http://window.location.href) = 'URL_of_Your_Thank_You_Page';
});
</script>
  1. Customize the Code:

    • Replace ‘yourFormId’ with the actual ID of your email sign-up form.
    • Replace ‘URL_of_Your_Thank_You_Page’ with the URL of your custom thank you page.
  2. Save Changes and Test:

    • Save the changes to the theme files.
    • Test the form submission process to ensure that users are redirected to the thank you page successfully.

I just need some help on where to insert it and what changes i need to make.

https://tryy.co.uk/?_ab=0&_fd=0&_sc=1

password - help

many thanks