Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
PersonalizeCloud Portal
Sitecore Personalize
        • Add a programmable decision
        • Create a programmable with the Code Assistant
        • Add a decision template
        • Examples of programmable decisions
        • Use custom fields
        • Including dates
        • Copy programmable decisions
        • Including print statements
        • Troubleshooting
    • Managing data systems
  • Using client-side JavaScript
  • Glossary
  1. Managing programmable decisions
  1. Sitecore Personalize
  2. Introduction to decisioning in Sitecore Personalize
  3. Managing programmable decisions
  4. Including print statements in programmable decisions

Including print statements in programmable decisions

It's best practice to include  print() statements in programmable decisions because they can help in debugging and understanding the flow of execution. These print() statements let you view the programmable output on the Logs tab, up until the point the code throws an error. This makes it easier for you to check the programmable functions that are working as expected and identify specific segments of the code that are causing errors when you test the decision model variant.

The following image shows an example of adding three print() statements for the guest's gender, city, and guestType to test a programmable.

Adding print statements in a programmable component to print guest data.

On the Test Canvas, on the Logs tab, you'll see the programmable test results, where the output for the guest's gender, city, and guestType are printed.

Displaying print statement results in the Logs tab.

For enhanced debugging, you can also print entire JavaScript objects using the print(JSON.stringify(example)); statement. This outputs the object in a readable, formatted JSON structure with line breaks and indentation.

If you have suggestions for improving this article, let us know!

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use