Enhancing Magento Newsletter Subscriptions: Adding First Name and Last Name Fields
As a new developer exploring the powerful e-commerce platform of Magento, you’ve likely discovered that the default newsletter subscription form only captures an email address. While this is a great starting point for collecting user information, adding first name and last name fields can significantly enhance your marketing capabilities.
The Default Newsletter Subscribe Experience
By default, when a customer navigates to Customer Account > Newsletter Subscription in Magento, they are presented with a simple form containing only an email field. This is adequate for basic newsletter signups but lacks personalization features that could improve engagement and segmentation.

Understanding the Newsletter Module
The default newsletter functionality in Magento is handled by the Magento_Newsletter module. This module provides a basic subscribe and unsubscribe feature using an AJAX-driven form. However, it does not natively support additional fields like first name or last name.
To extend this functionality, we’ll need to dive into theme customization and custom module development.
Customizing the Newsletter Form via Theme
The easiest way to add new fields to the newsletter subscription is by modifying your theme’s layout files. Here’s a step-by-step guide:
-
Locate your current theme: In your Magento root directory, navigate to
app/design/frontend/{your_vendor}/{your_theme}. -
Copy the default form: Find and copy the file
Magento_Theme/templates/newsletter/subscribe.phtmlinto your active theme’s template directory (usually withintemplates/newsletter). -
Modify the subscribe.phtml file: Open the copied file in a text editor. You’ll see the following line:
<input type="text" name="email" id="newsletter-validate-email" title="<?php /* @escapeNotVerified */ echo __('Enter your email address') ?>" class="input-text required-entry validate-email" /> -
Add first name and last name fields: Paste the following lines below the existing input field:
<div class="field firstname"> <label for="newsletter-firstname"><?php echo __('First Name:') ?></label> <input type="text" name="firstname" id="newsletter-firstname" title="<?php /* @escapeNotVerified */ echo __('Enter your first name') ?>" class="input-text required-entry validate-required-field"> </div> <div class="field lastname"> <label for="newsletter-lastname"><?php echo __('Last Name:') ?></label> <input type="text" name="lastname" id="newsletter-lastname" title="<?php /* @escapeNotVerified */ echo __('Enter your last name') ?>" class="input-text required-entry validate-required-field"> </div> -
Save and preview: Save the file, then navigate to Customer Account > Newsletter Subscription in the frontend. You should now see the added first name and last name fields.
Saving Data with Custom Module Development
Adding these fields to the form is only half the battle. We also need to store this data somewhere so it can be used later for segmentation, personalization, or other marketing purposes. This requires creating a custom module to extend Magento’s newsletter functionality.
To do this:
-
Create a new module: In your Magento root directory, navigate to
app/codeand create a new folder under the vendor namespace of your choice (e.g.,app/code/Magento/NewsletterExtension). -
Define the module configuration: Create a
composer.jsonfile within your new module with the following content:{ "name": "magento/newsletter-extension", "description": "Magento Newsletter Extension", "license": ["OSL-3.0"], "version": "1.0.0", "author": "Your Company Name, Your Email Address", "require": { "magento/product-community-edition": "2.4.*" } } -
Create the necessary files: You’ll need to create various XML configuration files and PHP classes to define your module’s functionality. This includes
registration.php,module.xml,etc/frontend/di.xml, etc.
This process requires a deeper understanding of Magento module development, which is beyond the scope of this post but can be explored further on Laravel Company’s guide to Magento custom module development.
Conclusion
Adding first name and last name fields to your Magento newsletter subscription is a vital step in enhancing your marketing capabilities. By following the theme customization steps outlined above, you can quickly add these fields without needing to dive deep into module development.
Remember, while this will display the fields on the frontend, you’ll need additional custom code (as described) to store and use this data effectively within Magento for segmentation and personalization purposes.
Don’t hesitate to reach out if you have any further questions about Magento customizations or e-commerce development needs. The team at Laravel Company is always ready to assist with your projects!