Congratulations on creating your first form in Sitecore XM Cloud Forms! Using the latest technology is always exciting, but now you're probably wondering, "How do I actually use this form on my site?" In this blog post, I'll guide you through the process step-by-step.
Logging in to Sitecore Cloud Portal
To get started, log in to the Sitecore Cloud portal. After logging in, choose the XM Cloud environment you want to work in. From the options provided, select Forms.
Activating Your Form
Before you can use your form, its status must be set to ACTIVE. To activate a form, you need to have both a valid form and a webhook configured. If you're just testing and don't have a proper webhook yet, you can use a simple tool like Webhook.site. It provides an easy interface to receive and inspect your data, as shown in the example below.
Note: Do not use this tool for sending sensitive data, as it's intended solely for testing purposes.
Adding a Webhook to Your Form
1. Creating a Webhook via the Overview Page
- Click on Webhooks in the top navigation bar to see an overview of existing webhooks.
- To create a new webhook, click the + Create Webhook button.
- Fill in the required information. If you're using Webhook.site, open it in a browser and copy your unique webhook URL.
- Set the Authentication Type to No Authentication. Give your webhook a name and paste the URL you copied into the URL field.
- Your webhook is now ready to be used with any form.
2. Creating a Webhook Directly in a Form
- Open the form that needs a webhook.
- Click the cogwheel in the navigation bar to open the settings.
- Under Choose Webhook, select the webhook you created earlier. If it isn't listed, click Manage Webhooks and follow the steps for creating a webhook via the overview page.
- Once done, close the settings and select your newly created webhook from the dropdown list.
Testing Your Webhook
- Click Test Webhook. This sends a filled-in form to test the webhook functionality.
- Review the data that will be sent. If you’re using Webhook.site, you'll see the data appear on your screen, allowing you to verify the connection is working correctly.
Activating Your Form
- Go to the Forms overview page and select the form you want to activate.
- Click the dropdown next to the Save and Exit button and choose Save and Activate.
- Confirm your action by clicking Activate. The site will process your request, and your form will be ready for use in XM Cloud.
Using Forms on a Page
- Navigate to XM Cloud and open the website of your choice.
- Go to the page where you want to add the form. Click on Components in the top left to switch views.
- Drag and drop the form onto the page. If the form isn't showing, it might still need activation. Refer to the Form Activation section to resolve this.
Fixing Component Placement
- Identify which component you want to use for your form. For example, you might need to drop a "global" container on the page.
- In XM Cloud, go to Tools in the top bar and click on Content Editor.
- Navigate to the Presentation folder of your site, such as Sitecore\Content\Headless Site\Headless Folder\Site name\Presentation.
- Locate the component that should allow forms to be added. If it's a placeholder, it will be in the Placeholder Settings folder.
- Click on the component name to open it.
- Scroll down to the Allowed Controls section and click Edit. Search for the BYOC Wrapper component, a generic Sitecore component that allows forms to be added to a page.
- Double-click on BYOC Wrapper and hit OK. Remember to click Save.