arrow_back_ios Blog How to Embed Custom Forms in Magento 2: A Comprehensive WebForms Guide

How to Embed Custom Forms in Magento 2: A Comprehensive WebForms Guide

calendar_today July 31, 2024 visibility 1765 views folder_open Development label WebForms, Form Builder, UX person By Vladimir Popov

Embedding forms in Magento 2 means placing a custom form on any page of your store. MageMe WebForms provides five embedding methods: CMS widget, Page Builder block, layout XML, PHP template call, and the Contact Us page replacement. Compatible with Luma, Breeze, and Hyvä on Magento 2.4.4+.

Seamless Form Integration: Elevating Your Magento 2 Store with Strategic Embedding

In the competitive world of e-commerce, efficient customer interaction is key. Forms play a crucial role in gathering information, feedback, and facilitating seamless communication. However, integrating forms into your Magento 2 website can often be a challenging task. This is where MageMe WebForms comes in, offering a powerful and user-friendly solution to effortlessly embed forms on your Magento 2 pages.

MageMe WebForms Features:

touch_app Easy to use

Intuitive interface makes form creation simple for all team members. No coding skills required, allowing you to quickly build and deploy forms.

view_module Over 30 field types

Choose from a wide variety of field types including text, dropdown, file upload, date picker, and more. Customize your forms to collect exactly the data you need.

rule Conditional logic

Create dynamic forms that adapt based on user input. Show or hide fields, change options, or display custom messages depending on previous answers.

linear_scale Multi-step forms

Break long forms into manageable steps to improve user experience and increase completion rates. Learn more about creating multi-step forms.

security Robust spam protection

Keep your forms secure with built-in spam protection features including CAPTCHA, honeypot fields, and IP blocking. Ensure the quality of your collected data.

open_in_new Popup forms

Engage users with attention-grabbing popup forms. Perfect for newsletters, special offers, or quick surveys. Check out our guide on creating popup forms.

In this guide, we'll explore various methods to embed forms created with MageMe WebForms into your Magento 2 website. From simple widget insertions to advanced developer techniques, you'll discover how to integrate forms seamlessly, enhance user experience, and boost conversions.

Magento 2 slide-out custom contact us form

While MageMe WebForms offers a comprehensive solution for form creation and embedding, it's always good to explore your options. If you're curious about how MageMe WebForms stacks up against other extensions, take a look at our roundup of the Best Magento 2 Form Builder Extensions in 2024. This comparison will help you make an informed decision about the best form builder for your specific needs.

Embed forms on any Magento 2 page
CMS widgets, Page Builder, layout XML — choose your embedding method.

Form Embedding Techniques: From Basic to Advanced

Method Difficulty Best For Coding?
CMS Page / Widget Easy Contact page, landing pages, any CMS page No
Page Builder Block Easy Visual page layouts, drag-and-drop placement No
Contact Us Replacement Easy Replace default contact form globally No
Layout XML Medium Sidebar, footer, product pages, category pages XML only
PHP Template Call Advanced Custom .phtml templates, programmatic embedding PHP

All methods work with Luma, Breeze, and Hyvä themes. The first three require no coding and can be set up entirely from the Magento admin panel.

MageMe WebForms offers a range of methods to embed forms on your Magento 2 website, from simple to advanced. Let's explore these user-friendly techniques:

link Custom URL

Create a dedicated URL for your form using the Search Engine Optimization settings:

  1. In your form settings, navigate to the "Search Engine Optimization" tab.
  2. Set a unique URL Key for your form (e.g., "customer-feedback").
  3. Your form will now be accessible at yourdomain.com/customer-feedback.

This method is ideal for sharing forms via email or social media, enhancing visibility and accessibility.

SEO search engine optimization settings in Magento 2 Forms

insert_drive_file Insert in CMS Page

Easily add forms to any CMS page using the Insert Widget button:

  1. Edit your desired CMS page in the Magento 2 admin panel.
  2. Click the "Insert Widget" button in the content editor.
  3. Choose any "WebForms:..." from the widget type dropdown.
  4. Select your pre-designed form and adjust settings as needed.
  5. Click "Insert Widget" to embed the form on your page.

This no-code approach is perfect for marketing teams and content managers.

Click insert widget button in Magento 2

view_quilt Page Builder Integration

For visual design enthusiasts, use Magento 2's Page Builder to drag and drop WebForms blocks:

  1. Install the additional composer package: composer require mageme/module-webforms-3-page-builder
  2. In Page Builder, drag the WebForms block to your desired location.
  3. Configure the block settings to select your form.

This method offers precise control over form positioning and design integration.

Drag and drop custom forms in Magento 2 page builder

slideshow Slide-out Form

Create an unobtrusive yet accessible form that slides out from the page edge:

  1. Go to Stores > Configuration > MageMe Extensions > WebForms.
  2. In the "Slide-out Form" section, enable the feature.
  3. Select the form you want to display.
  4. Customize options like position, button text, colors, and dimensions.

Slide-out forms are excellent for contact forms, newsletter signups, or quick surveys.

Slide out form settings in Magento 2

contact_mail Custom Contacts Page

Replace the default Magento 2 contact form with your custom WebForms creation:

  1. Create your custom contact form using WebForms.
  2. Navigate to Stores > Configuration > WebForms.
  3. In the "Contacts Form" section, enable the feature and select your custom form.
  4. Save the configuration to replace the default contact page with your custom form.

For a detailed guide on customizing your contact page, check out our tutorial: How to Customize Contact Us Form in Magento 2.

Contact us custom form settings in Magento 2

open_in_new Button With Popup Form on Product Pages

Engage customers on product pages with a button that triggers a popup form:

  1. Navigate to Content > Widgets in your Magento 2 admin panel.
  2. Click on "Add Widget" to create a new widget instance.
  3. Set the Type to "WebForms: Button With Popup" and choose your desired design theme.
  4. Click "Continue" to proceed to the Storefront Properties section.
  5. Give your widget a descriptive name and assign it to the desired store views.
  6. In the Layout Updates section:
    • Set "Display on" to "All Product Types"
    • Choose "Specific Products" if needed
    • Set "Container" to "Product View Extra Hint"
  7. In the Widget Options section:
    • Select the form you want to display in the popup
    • Customize the button text, style, and popup settings as needed
  8. Save the widget configuration.
Add custom form widget in Magento 2
lightbulb Tip: You can create multiple widget instances to display different forms on different sets of products, allowing for highly targeted customer interactions.

Developer-Friendly Form Integration Methods

For developers seeking more control, MageMe WebForms provides code-based integration options:

code PHP Integration
getLayout()->createBlock(
    'MageMe\WebForms\Block\Form',
    null,
    ['data'=>[
        'form_id' => 1
    ]]
)->toHtml();
?>
code XML Layout Updates

    
        
            1
        
    

These methods offer precise placement and advanced customization options, perfect for tailoring forms to specific page layouts or dynamic content requirements.

For a step-by-step guide on creating custom forms from scratch in Magento 2, refer to our article: How to Create Custom Form in Magento 2. This resource provides in-depth instructions for developers looking to build forms tailored to their exact specifications.

Enhancing User Experience with Dynamic Form Loading

MageMe WebForms goes beyond static embedding, offering features to enhance user engagement and site performance:

open_in_new Popup Forms

Implement popup forms to capture user attention without disrupting the browsing experience. This is particularly effective for newsletter signups or quick surveys.

Magento 2 popup custom form embed in catalog page

For a deep dive into creating engaging popup forms, check out our detailed guide: How to Create Popup Forms in Magento 2.

speed Asynchronous Form Loading

Enable the "Asynchronous Form Loading" option in the Design Settings tab to improve page load times. This feature is especially beneficial for pages with multiple forms or complex layouts.

Asynchronous loading of custom form widget in Magento 2

By leveraging these dynamic loading options, you can significantly improve your site's user experience and performance while effectively capturing valuable user data.

Real-World Usage Scenarios

Let's explore how different businesses can leverage MageMe WebForms:

star E-commerce Product Feedback

Embed a product review form in a tab on product pages, allowing customers to easily submit reviews and ratings.

how_to_reg B2B Registration Form

Implement a custom B2B registration form to capture detailed information from potential business customers. Learn more about our B2B Custom Registration Form solution.

event Event Registration

Place an event registration form in the right column of your blog posts about upcoming webinars or in-store events.

support Customer Support

Implement a popup support request form triggered by inactivity on checkout pages to reduce cart abandonment.

email Newsletter Signups

Add a non-intrusive slide-out newsletter signup form on all pages to boost your email subscriber list.

settings Custom Product Configuration

Create a multi-step form for complex product customization, allowing customers to configure made-to-order items. Enhance this with our Advanced Product Options extension.

Troubleshooting Common Embedding Issues

While embedding forms with MageMe WebForms is generally straightforward, you might encounter some issues. Here are solutions to common problems:

error Forms not displaying
  • Ensure that the WebForms module is properly installed and enabled.
  • Clear your Magento cache and check for JavaScript errors in the browser console.
brush Styling conflicts

If your form doesn't match your site's design, use the custom CSS options in the form settings to override conflicting styles.

speed Performance issues

For pages with multiple forms, enable asynchronous loading to improve page load times.

phone_android Mobile responsiveness

If forms aren't displaying correctly on mobile devices, review the responsive settings in the form builder and test on various devices.

Conclusion: Elevate Your Magento 2 Store with Embedded Forms

Integrating forms into your Magento 2 website doesn't have to be a daunting task. With MageMe WebForms, you have a versatile toolkit at your disposal to create, embed, and manage forms that enhance user engagement and drive conversions.

From simple widget insertions to advanced developer methods, MageMe WebForms offers solutions for every skill level and requirement. By strategically placing forms throughout your site using techniques like slide-out forms, product tab integrations, and asynchronous loading, you can create a more interactive and user-friendly shopping experience.

Ready to transform your Magento 2 store with powerful, easy-to-embed forms?

Key Takeaways

  • Five embedding methods — widget, Page Builder, layout XML, PHP template, Contact Us replacement.
  • Widget is the easiest — place a form on any page without editing code.
  • Popup and slideout modes — forms as inline elements or overlay triggers.
  • Asynchronous loading — forms load without impacting page performance.
  • SEO-friendly — embedded forms don’t create duplicate content issues.

FAQs: Magento 2 Form Embedding Made Simple

help_outline Can I embed multiple forms on a single page? expand_more

Yes, MageMe WebForms allows you to embed multiple forms on a single page using any of the methods described above. Use unique identifiers for each form to avoid conflicts.

help_outline Is it possible to style the embedded forms to match my website's design? expand_more

Absolutely! MageMe WebForms offers extensive styling options to ensure your forms seamlessly integrate with your site's aesthetic. You can use custom CSS, choose from pre-designed themes, or create your own to match your brand perfectly.

help_outline Are the embedded forms mobile-responsive? expand_more

All forms created with MageMe WebForms are fully responsive by default, ensuring a great user experience across all devices. You can further customize the mobile layout in the form builder if needed.

help_outline How do I handle form submissions? Can they be integrated with my existing systems? expand_more

MageMe WebForms offers various options for handling submissions. You can view them in the Magento admin panel, receive email notifications, or integrate with popular CRM and marketing automation tools. The extension also supports webhook integrations for custom workflows.

help_outline Is there a limit to the number of forms I can create and embed? expand_more

There's no limit to the number of forms you can create or embed with MageMe WebForms. Your only constraint is your server's resources and your imagination!

help_outline How secure are the forms created with MageMe WebForms? expand_more

Security is a top priority. MageMe WebForms includes built-in spam protection, CAPTCHA options, and adheres to Magento 2's security best practices to keep your data safe.

Using WebForms? Share Your Experience!

Vladimir Popov
About the Author
Vladimir Popov
verified Founder & Lead Developer, MageMe

Vladimir Popov is the founder and lead developer of MageMe (ACTEK d.o.o., Ljubljana, Slovenia). He has been building on Magento since 2011, starting with Magento 1 and moving to Magento 2 at its 2.0 beta. He wrote the first versions of every MageMe extension himself and still reviews every release.

His focus is clean, performance-first PHP code that plays nicely with Hyvä, Breeze, and stock Luma themes. He writes most of the technical content on the MageMe blog and answers support tickets personally for complex issues.