Category: Sitecore

Algolia Search Provider for Sitecore 10.2.1

Algolia Search Provider for Sitecore 10.2.1

The Algolia Search Provider for Sitecore is a powerful integration combining robust content management capabilities with Algolia’s lightning-fast, full-text search engine.

This provider enables Sitecore-driven websites and applications to deliver instant, relevant, and highly customizable search experiences to end-users, ensuring faster content discovery and improved user engagement.

While exploring, I found that Dmitry Harnitski and Peter Procházka have implemented the Algolia Search Provider for Sitecore 9.1 and previous versions. Thank you so much!

https://github.com/dharnitski/Sitecore.Algolia

https://github.com/chorpo/Sitecore.Algolia/tree/sitecore91

Upgrading to Sitecore 10.2.1

The following are the steps taken for upgrading Sitecore 10.2.1 – 

  •  I forked from Peter Procházka’s Sitecore 9.1 branch

https://github.com/chorpo/Sitecore.Algolia/tree/sitecore91

  • Upgraded the Sitecore NuGet packages to 10.2.1.

Sitecore-Algolia-Search-Provider-10-2-1-Upgrade-1.png

  • Algolia.Search NuGet package upgraded 6.12.1

Sitecore-Algolia-Search-Provider-10-2-1-Upgrade-4.png

Sitecore-Algolia-Search-Provider-10-2-1-Upgrade-2.png

  • Finally, able to build the solution successfully. 

Sitecore-Algolia-Search-Provider-10-2-1-Upgrade-3.png

  • After the build was successful, I shifted the module to the existing solution.
  • I didn’t get a chance to upgrade the unit test project. If you have upgraded, please let me know.

The module is checked into the following repository.

https://github.com/Madhumidha/Sitecore.Algolia/tree/Sitecore1021

The repo has all the instructions on how to set up and configuration details.

Hope this helps.

Happy Sitecoring!

 

0

Sitecore Personalize : Custom Web Template Integration


Sitecore Personalize Custom Web Template Integration.png

I’ve been delving deeper into Sitecore Personalize and have discovered how to incorporate its custom Web Templates into the website.

Let’s dive into the process of creating custom Web Templates and how to utilize them in Web Experiences.

Create Web Template

Let’s navigate to Web Templates in Sitecore Personalize and create it.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-1-2.png

 

The Web Templates have the high flexibility of HTML, CSS, JavaScript, and API tabs to configure.

  • HTML: Define the structure and content of your web template. This is where you can create the basic layout and elements that will be displayed on your website.

  • CSS: Style your web template to match your brand’s look and feel. You can add custom styles to ensure that the template is visually appealing and consistent with your website’s design.

  • JavaScript: Add interactivity and dynamic behavior to your web template. JavaScript allows you to create engaging user experiences by adding features like animations, form validations, and more.

  • API: Configure API responses to integrate with your organization’s data.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-2-1.png

 

To build the custom web template, let’s say I want to Personalize the About page of my blog.

To create HTML and CSS, we don’t need to dive into the code. A tool called SnipCSS can turn any section of the website into a reusable component.

SnipCSS

SnipCSS is a powerful tool designed to help web developers extract CSS and HTML snippets from any web element or widget. The main key feature is extracting all HTML, images, and CSS with a single click.

Download the Chrome extension – https://chromewebstore.google.com/detail/snipcss/hbdnoadcmapfbngbodpppofgagiclicf

After installing, there is no need for signup unless Pro features are needed.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-6.png

 

Running the SnipCSS

Let’s hover over the section we want to personalize and run the Snip CSS.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-8.png

 

A cute Kiwi will come, analyze the section in a second, and open a new tab with HTML and CSS of the section.

Sitecore CDP and Personalize - Web Templates-Experiences-9.png

 

Web Template HTML and CSS

Let’s copy and paste the HTML and CSS into the Web Template that we created.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-13.png

 

Convert all hard-coded text into parameters to ensure it can be reused throughout the website.

Let’s convert the image source into a dynamic image URL.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-10-1.png

To make it configurable, substitute it with a parameter name and type

[[ Image URL  | string ]]

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-11.png

 

Similarly, I have configured more fields.

[[ Title | string ]]

[[ Description | string ]]

[[ Certification 1 | string ]]

[[ Certification 2 | string ]]

[[ Certification 3 | string ]]

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-12.png

 

Web Template JavaScript

Now we need to tell whether the section needs to be replaced/added after some ClassName or ID of the page.

Let’s replace the section HTML with the ID of the div.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-15.png

Sitecore CDP and Personalize - Web Templates-Experiences-14.png

Settings

Let’s add a description for the web template and select an icon from the predefined options, as custom uploads are not allowed.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-17.png

 

Preview

Select the Render a Preview Experience checkbox and it adds a new tab to the web template for previewing.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-16.png

 

Publish/Draft

Enable the Publish button to activate live mode, which locks the web template.

To revert it to draft mode, disable the Publish button.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-18.png

Create Experience

Let’s build an Experience using the Web Template we just created.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-19.png

 

Create a Variant

Now variant lists our custom Web Template, let’s go.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-20.png

 

Enter the field values for Image URL, Title, Description, Certification 1, Certification 2, and Certification 3.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-21.png

 

Page Targeting

It is specifically for the About page, let’s add a condition.


Sitecore-CDP-and-Personalize-Web-Templates-Experiences-22.png

Preview

Let’s preview it for the About page URL.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-23.png

It’s working! Tada!

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-23.png

Live mode

Let’s start the Experience – you can start now or schedule it later time.

Sitecore CDP and Personalize - Web Templates-Experiences-24.png

After a few seconds, it’s live now – If a notification is added, it will email that it’s published.

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-25.png

Let’s reload the page. Yahoo!!

Sitecore-CDP-and-Personalize-Web-Templates-Experiences-4.png

 

Hope this helps.

Happy Sitecoring!

0

Sitecore Forms : Custom Submit Action to Create and Publish Content Item (Part 2)

In Part 1, we saw

  • Create Custom Submit Action in Sitecore
  • Create a code-behind class that inherits SubmitActionBase
  • Create a secure API that can create and publish an item

https://madhuanbalagan.com/sitecore-forms-custom-submit-action-to-create-and-publish-item-from-form-data-part-1

Now, let’s focus on 

  • Create a separate Authorization in the Identity Server for Forms 
  • Create a Controller to bridge between Custom Submit Action and API call
  • Set the Custom Submit Action fields

1. Create a separate Authorization in the Identity Server for Forms 

Add the FormsServerClient node and its value to the Identity Server’s Sitecore.IdentityServer.DevEx.xml file. After making the change, make sure to IIS Reset for the change to be in effect. 

Note: Don’t forget to add transforms for ClientSecret!

 

Ideally, you can call it in Postman to verify that it’s generating a token using Form’s ClientID and ClientSecret values mentioned in the Sitecore.IdentityServer.DevEx.xml file.

Now that the config is all set to have its own ClientID and ClientSecret, let’s set up the Authorize method with BearerToken specifically for Form’s Identity Credentials.

The SitecoreRestServices handles authenticated HTTP requests to Sitecore’s REST APIs, managing access tokens and retrying requests if authentication fails. It uses dependency injection to configure the HTTP client and obtain the necessary settings.

2. Create a Controller to bridge between Custom Submit Action and API call

Let’s bridge the Custom Submit Action and API call – The CustomController class extends SitecoreController and uses dependency injection to obtain an instance of ICreateAutoPublishService.

It defines a CreateAndPublish method – HTTP POST endpoint that processes CreateAndAutoPublishModel, calls the service to create and publish content, and returns a JSON response indicating success or failure.

The method includes error handling to return appropriate HTTP status codes and messages for different exceptions.

3. Set the Custom Submit Action fields

The final step – Let’s set the Model Type and Error Message based on the class we created. 

Publish the form and its related items. It should be good to go!

Hope this helps.

Happy Sitecoring!

0

Integrating External Website into Coveo Index for Seamless Search in Sitecore

I recently faced a scenario where I needed to integrate an external website into the Coveo Index and utilize it along with Sitecore Items on the website.

Let’s take my blog as an external data source and integrate it into the Coveo Index.

Trial Account

Feel free to create a new trial account and explore yourself – No credit card is needed it’s free and valid for 14 days. 

https://www.coveo.com/en/free-trial

Sitecore-Coveo-Extenal-Data-Source-Index-1.png

Note: Please make sure to use your business email.

Sources

After signing up, navigate to the Sources section.

Sitecore-Coveo-Extenal-Data-Source-Index-2.png

 

There are many sources available like Sitecore, Web, Sitemap, Sitemap, and many more.


Sitecore-Coveo-Extenal-Data-Source-Index-3.png

Web Source

Let’s focus on Web sources since we want to add my blog.

There are two Web sources available on-prem crawler and cloud-based crawler. Let’s choose the cloud-based crawler that is with the cloud icon on the right.

Sitecore-Coveo-Extenal-Data-Source-Index-4.png

When I start filling in my blog URL, it automatically detects the Sitemap for the website – Switching to the Sitemap URL for better Indexing performance.

Sitecore-Coveo-Extenal-Data-Source-Index-5.png

 After switching, it automatically updated to a Sitemap source with the appropriate sitemap URL.

Sitecore-Coveo-Extenal-Data-Source-Index-6.png

Content Security

The next step in the setup is Content Security.

We can permit for 

  • Same users and groups as in your content system (Grayed out due to trial account)
  • Everyone – Anonymous can access
  • Specific users and groups

By default, the everyone option is selected this would be best for public-facing content. 

Let’s change it to Specific users and groups for the demo.

Sitecore-Coveo-Extenal-Data-Source-Index-8.png

Add Source

Once added after a few minutes the source will be available. You can review other settings if further tuning is needed.

Sitecore-Coveo-Extenal-Data-Source-Index-9.png

 

Rebuild Source

Hit save and rebuild source that will initiate the rebuilding of the index.

Download logs provide more in-depth information – It’s super helpful when you face any issues.

Sitecore-Coveo-Extenal-Data-Source-Index-10.png

 

Content Browser

Once the rebuild is completed, Open the Content Browser from the left navigation under content to see the items in the index.


Sitecore-Coveo-Extenal-Data-Source-Index-11.png

 

It took only a couple of minutes to rebuild the entire blog this depends on the content of the site.

Yay! My entire blog is reindexed and ready to be consumed.

Sitecore-Coveo-Extenal-Data-Source-Index-12.png

 

Now, in the Sitecore Coveo Search interface, I could include this as an external source and use the items in the index. We could also set up a blog template and display the results with images. The source type can also be used as a facet.

Hope this helps.

Happy Searching!

0

Sitecore Forms : Custom Submit Action to Create and Publish Content Item(Part 1)

 

Problem

I encountered a situation that the website was internally facing, which needed a form that would not save the data in the Experience Forms database. Also the data needs to be saved as an Item in the master database so it could be published and consumed in a listing page.

At first, I considered creating a Custom Submit Action to create and publish an item. However, I later realized that the CD server lacked access to the CM server, preventing it from directly generating an item in the master database. So, I came up with the idea of creating a custom API service and combining it with a custom submit action.

Solution

To implement this followed this process

  • Create Custom Submit Action in Sitecore
  • Create a code-behind class that inherits SubmitActionBase
  • Create a secure API that can create and publish an item
  • Create an API authorization user in the identity server 
  • Create a Controller to proxy between Custom Submit Action and API calls
  • Set the Custom Submit Action fields

 

1. Custom Submit Action in Sitecore

Create the custom submit action in the following path /sitecore/system/Settings/Forms/Submit Actions.

Sitecore_Forms_1.png

 

2. Create a code-behind class that inherits SubmitActionBase

Create a class that inherits the SubmitActionBase class and overrides the Execute method which calls the API asynchronously to create and publish an item.

The CreateAndAutoPublish class extends SubmitActionBase<string> and is designed to handle form submissions in Sitecore, creating and auto-publishing content items.

It uses dependency injection to obtain instances of IHttpClientFactoryBaseSettings, and ISitecoreRestServices, which are lazily initialized. The ExecuteAction method validates the form submission context and parameters, then calls the Execute method to prepare a model from form fields, serialize it to JSON, and send it to a Sitecore API endpoint using an HTTP POST request.

The class includes helper methods to extract values from form fields and handles errors by logging them and adding them to the form submission context’s error collection.

 

3. Create an API call that creates and publishes the item  

The API call does the following things – 

  1. Creates an item under a specified folder
  2. Move and Sync the item into a bucket
  3. Publish the item
  4. Clear the Sitecore cache
  5. Ensure the published item is indexed or force index the item
  6. Clear the Vercel Cache for frontend

In Part 2, we will see how to

  • Create an API authorization user in the identity server 
  • Create a Controller to proxy between Custom Submit Action and API calls
  • Set the Custom Submit Action fields

Hope this helps.

Happy Sitecoring!

1

Instantly Download Sitecore Logs from Azure Web Apps

I had to troubleshoot an issue and started with logs. Since we are in Azure PaaS, I used Kudu or App Service Explorer to search for recent logs. It was absolutely time-consuming.

AzureTools comes to the rescue. It is a simple .aspx page that can be dropped into CM environments, and download logs in seconds.

https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0420753

Download the recent AzureTools-1.2.0 (It should work with any Sitecore version) – 

Download AzureTools

Unzip and drop the AzureTools.aspx in https://[CM_Site]/sitecore/admin folder

Sitecore-AzureTools-Azure-Logs-ToolKit-3.png

 

Now it’s ready to download logs from App Insights, Azure Search, and Kibana Logs – https://[CM_Site]/sitecore/admin/azuretools.aspx

Sitecore-AzureTools-Azure-Logs-ToolKit-4.png

To pull logs from App Insights, need the Application ID and API Key.

Application ID:

Navigate to the Azure App Insights Resource -> Configure -> API Access.

Sitecore-AzureTools-Azure-Logs-ToolKit-5.pngAPI Key:

 – Create the API Key with Read Telemetry access.

Remember to save the key in notes, you can’t get it after creation!

Now I was excited to download logs – 

But then it’s erroring out – 

Sitecore-AzureTools-Azure-Logs-ToolKit-1.png  

The console is showing the following error –

azuretools.aspx:2082 Refused to connect to ‘https://api.applicationinsights.io/v1/apps/e…ityLevel%2C%20customDimensions.ThreadName%2C%20customDimensions.StackTrace’ because it violates the following Content Security Policy directive: “default-src ‘self’ mailto: tel: ‘unsafe-inline’ ‘unsafe-eval'”. Note that ‘connect-src’ was not explicitly set, so ‘default-src’ is used as a fallback.

 

It made me curious to check the Web.Config – I couldn’t find the content-src node, added the following line.

connect-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval’ https://api.applicationinsights.io; 

 <location path="sitecore">
<system.webServer>
<httpProtocol>
<customHeaders>
<!--Adding mailto: and tel: which are currently blocked in iframes. Seems like a Chrome bug that never got fixed: https://bugs.chromium.org/p/chromium/issues/detail?id=663325 -->
<add name="Content-Security-Policy"
xdt:Locator="Match(name)"
xdt:Transform="SetAttributes"
value="default-src 'self' mailto: tel: 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' 'unsafe-inline' https://fonts.gstatic.com; upgrade-insecure-requests; block-all-mixed-content;"/>
value="default-src 'self' mailto: tel: 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' 'unsafe-inline' https://fonts.gstatic.com; connect-src 'self' 'unsafe-inline' 'unsafe-eval' https://api.applicationinsights.io; upgrade-insecure-requests; block-all-mixed-content;"/>
</customHeaders>
</httpProtocol>
</system.webServer>
</location>

Now I’m able to pull logs, preview traces, and exceptions.

 Sitecore-AzureTools-Azure-Logs-ToolKit-2.png

 

Utilize the Extended View for more filtered options.

Hope it helps.

Happy Sitecoring!

0

Automate Sitecore Content Synchronization using Sidekick PowerShell

  
Sitecore-Content-Sidekick-Powershell.png

I wanted to set up a daily Sitecore content synchronization to lower environments to ensure they are updated with the latest content from Production every morning.

The Sitecore Sidekick PowerShell module came to the rescue – Thank you Jeff Darchuk for the excellent module! One of its key advantages is that it eliminates the need to pass usernames or passwords for higher environments. 

https://github.com/JeffDarchuk/SitecoreSidekick?tab=readme-ov-file#scripting-sidekick

Installation:

Simply copy the Sidekick folder from the URL below and paste it into your PowerShell Modules on a Windows machine.

https://github.com/JeffDarchuk/SitecoreSidekick/tree/master/Scripting

Basically, it should reside in one of the paths found under $env:PSModulePath

Example: C:\Users\[USER]\Documents\WindowsPowerShell\Modules\SitecoreSidekick

P.S. I hope you have the Sidekick module installed, it needs a SharedSecret to communicate to the higher environments.

Content Sync:

After successfully installing the Sidekick PowerShell module, I created the following script to sync the Home page and its children from the Production environment to the QA environment.

 

Similarly, I created the following script for the Data folder on the SXA site, excluding the Sitewide Configuration item.

Scheduling:

With the scripts ready, I have scheduled both using Powershell Scripts Command to run every 12 hours to fetch items.

Sitecore-Sidekick-Content-Sync-Powershell.png

 

Sitecore-Sidekick-Content-Sync-Powershell-2.png

Hope this helps.

Happy Sitecoring!

0

2024 – Contributions

The 2024 year has been great with presenting at Sitecore Symposium, and various Sitecore User Groups worldwide. 

Symposium Presentation: 

 

Blog Posts : 

 

Presentations : 

 

Contributions: 

  • Dec 22, 2023 – Feedback/Review for Sitecore Content Hub Administrator Certification Exam – 
  • Dec 15, 2023Feedback for Sitecore MVP Program – 
  • Mar 01, 2024 – Sitecore CDP & Personalize Certification Exam Beta review
  • April 19, 2024 – Reviewed Sitecore Dev 10 Beta Exam

 

 Co-organized SUG-Pittsburgh Meetups: 

 

YouTube – Videos published for SUG – Pittsburgh  

  • Jan 02, 2024Abstracting personalization – CP
  • Mar 20, 2024Sitecore XM Cloud 101 – A Beginner’s Guide
  • Apr 03, 2024From Brainstorm to Brilliance: The Untold Story of Sitecore Hackathon
  • Apr 12, 2024Sitecore XM Cloud Forms
  • May 6, 2024Achieving Behavioral Personalization with XM Cloud Plus 
  • May 22, 2024Sitecore Search and XM Cloud – Experiences and Learnings
  • June 11, 2024Tips and Tricks for Next.js and Sitecore Headless
  • Aug 5, 2024 Content Hub Web Client SDK – Internal & External Integrations
  • Sep 3, 2024Sitecore Troubleshooting 101
  • Oct 8, 20248 Content Migration Pitfalls to Avoid and Lessons Learned

 

Co-organized SUG-Philadelphia Meetups: 

 YouTube – Videos published for SUG – Philadelphia 

 

Conferences I attended: 

  • Symposium 
  • MVP Summit 
  • MVP Lunches   
  • MVP Webinars 
  • All SUG Pittsburgh and Queen City meetups  
  • Many SUG Boston/ Columbus/ Atlantic meetups   

 

Plans for 2026: 

Learn and contribute: 

  • Composable DXP 
  • Sitecore Saas Offerings 
  • Containerization 

Co-organize : 

  • Monthly SUG-Pittsburgh meetup 
  • Quarterly SUG-Philadelphia meetup 

Present: 

  • SUGCON EU/Symposium 
  • SUG Meetups 

Happy New Year! Happy Sitecoring!

0

Sitecore Sidekick Installation and Setup

Blog-Sitecore-Sidekick-Install-Setup.png

 

 

 

 

 

 

 

 

 

 

 

 

 

While working on a Sitecore 10.2.1 XM project, we relied on packaging content from upper environments or restoring the database to pull content locally, which was quite time-consuming.

The Sitecore Sidekick module (a big thanks to Jeff Darchuk) was a lifesaver for quickly pulling content into local or lower environments.

The latest Sidekick version is 1.7 and I was wondering which version will be compatible with Sitecore 10.2.1 and realized it doesn’t matter! 

Installation 

In NuGet, install the following modules in one of the Foundation projects or create a new helix module.

  • SitecoreSidekickFoundation
  • SitecoreSidekickContentMigrator
  • SitecoreSidekickCore
  • SitecoreSidekickAuditLog
  • SitecoreSidekickEditingContext

Sitecore-sidekick-install-download-content-migration-1.png

Note: You can skip AuditLog and EditingContext if don’t want it.

After installation, you will see the following DLLs in the bin folder

Sitecore-sidekick-install-download-content-migration-2.png

Configuration

  • Create a folder Sidekick under App_Config/Include in the Foundation layer.
  • Add the following Config files as it is, no changes are needed.

Sitecore-sidekick-install-download-content-migration-3.png

AuthenticationSecret – Generate a random GUID

Server List

<server desc="QA">https://[your_qa_cm_url]</server>

<server desc="QA">https://[your_qa_cm_url]</server>

<server desc="QA">https://[your_qa_cm_url]</server>

 

Publish the solution, now you will see Side Sidekick added to the menu bar!

Sitecore-sidekick-install-download-content-migration-4.png

Sitecore-sidekick-install-download-content-migration-5.png

 

Content Migrator

It is ready to pull content (make sure it’s deployed to higher environments)

Sitecore-sidekick-install-download-content-migration-6.png

 

Audit Log 

It’s quite helpful to review all content changes in graphic and detailed mode.

Sitecore-sidekick-install-download-content-migration-7.png

Sitecore-sidekick-install-download-content-migration-8-1.png

 

Editing Context

Quickly edit content without switching between databases using Editing Context.

Sitecore-sidekick-install-download-content-migration-9.png

References

  • https://jeffdarchuk.com/2016/10/24/sitecore-sidekick-content-migrator/
  • https://kamsar.net/index.php/category/Unicorn/

Hope this helps.

Happy Sitecoring!

1