๐Ÿ”” Triggered Experiences Using Custom Events in Sitecore Personalize

 

๐Ÿงฉ Use Case

By default, when you create a Triggered Experience in Sitecore Personalize, it can be triggered by a set of predefined system events like:

  • guest_created

  • identify

  • session_end

These events are automatically fired through Sitecore CDP, and developers typically don't need to manually trigger them.

However, there are real-world scenarios where you want a Triggered Experience to be initiated by custom user actions, such as:

  • Submitting a form

  • Clicking a button

  • Completing a survey

In this blog, we’ll walk through how to create a custom event in Sitecore CDP and use it to trigger a Triggered Experience when a Personal Details form is submitted.


๐Ÿ› ️ Section 1: Code Implementation Using Cloud SDK

๐Ÿ’ก Prerequisite: Make sure your Sitecore Cloud SDK setup is complete. If not, refer to my earlier blog:
Beginners Guide - Integrating Sitecore Cloud SDK

✅ Step 1: Create the Form Page

Let’s assume we have a Personal Details form. When the form is submitted, a method is triggered that sends the form data to Sitecore CDP using the Cloud SDK.

Here's the sample code snippet for sending the custom event:

try { await event({ type: 'PERSONAL_DETAILS_FORM_SUBMITTED', // Custom Event Identifier channel: 'WEB', currency: 'USD', page: route?.name, pageVariantId, language, payload: { Name: formData.firstName + ' ' + formData.surname, IDNumber: formData.idNumber, Cellphone: formData.cellphone, Income: formData.income, }, }); } catch (err) { console.error('Error sending event to CDP:', err); }
  • The type value (in this case: 'PERSONAL_DETAILS_FORM_SUBMITTED') is critical. This identifier will be used later in Sitecore Personalize to configure the trigger.

  • Customize the payload fields according to your form data structure.

๐Ÿงช Test It




Once submitted, the form data is sent to Sitecore CDP and is visible in the Guest Profile Timeline under the event name 'PERSONAL_DETAILS_FORM_SUBMITTED'.


⚙️ Section 2: Creating a Triggered Experience in Sitecore Personalize

๐ŸŽฏ Step 1: Create the Triggered Experience

  1. Go to Sitecore Personalize.

  2. Navigate to the Experiences section.

  3. Choose Triggered as the type of experience.

  4. Click Create and give it a meaningful name (e.g., PDSubmittedExperience).



๐Ÿ› ️ Step 2: Configure the Experience




There are two main parts to configure:

a. Webhook Composer

Set up a connection and configure the webhook composer. This defines what action should be taken when the event is triggered (e.g., sending an email, invoking a 3rd-party API, etc.).




b. Trigger Configuration




This is where the magic happens.

  • Go to the Trigger tab.

  • Click Edit Trigger.

  • Add a custom event trigger with the following details:

FieldValue
Event Name:Personal Details Submitted
Event Description:Triggered on personal details form submission
Event:PERSONAL_DETAILS_FORM_SUBMITTED

๐Ÿ“ Important: The Event field value must exactly match the type you defined in the SDK ('PERSONAL_DETAILS_FORM_SUBMITTED'), otherwise the trigger will not activate.



 

✅ Step 3: Save and Publish

Once your webhook and trigger are configured, save and publish the experience.


๐Ÿ” Verification

To verify:

  1. Go to the Guest Profile in Sitecore CDP.

  2. Check the Timeline after submitting the form.

  3. You should see the PERSONAL_DETAILS_FORM_SUBMITTED event.

  4. If configured correctly, the Triggered Experience (e.g., an email or notification) should have been executed.




✅ Summary

Using custom events in Sitecore Personalize allows you to go beyond system-generated triggers and create personalized experiences based on specific user interactions, such as form submissions.

Key Takeaways:

  • Use the Sitecore Cloud SDK to send custom events.

  • Match the event.type in your code with the trigger configuration in Sitecore Personalize.

  • Use Webhook Composer to define what happens when the event is triggered.

  • Always test by checking the Guest Timeline i

Comments

Popular posts from this blog

Solrcloud With Zookeeper -Single server setup

Render Sitecore Experience Forms Using Sitecore XP 10.4 with a Headless Approach (Next.js + JSS SDK)

Next.js with XM Cloud EDGE and GraphQL