๐ 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:
-
The
typevalue (in this case:'PERSONAL_DETAILS_FORM_SUBMITTED') is critical. This identifier will be used later in Sitecore Personalize to configure the trigger. -
Customize the
payloadfields 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
-
Go to Sitecore Personalize.
-
Navigate to the Experiences section.
-
Choose Triggered as the type of experience.
-
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:
| Field | Value |
|---|---|
| Event Name: | Personal Details Submitted |
| Event Description: | Triggered on personal details form submission |
| Event: | PERSONAL_DETAILS_FORM_SUBMITTED |
๐ Important: The
Eventfield value must exactly match thetypeyou 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:
-
Go to the Guest Profile in Sitecore CDP.
-
Check the Timeline after submitting the form.
-
You should see the
PERSONAL_DETAILS_FORM_SUBMITTEDevent. -
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.typein 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
Post a Comment