How to Add Content Testing to Sitecore Workflow
To give the option to Content Test in workflow you need to create new Workflow Commands under a new or existing Workflow State, commonly the State before Item is publishable. In this example, the Content Test will be created on the Review State before the Item is moved to the Approved State for publishing.
Workflow Commands
First create two new Workflow Commands named ‘Approve with Test‘ and ‘Approve without Test‘ under the Workflow state that precedes the Publishable state.
The first Workflow Command is responsible for displaying the Test Editor to the User before ultimately moving the Item into the publishable State. The latter will remove all tests from the item and move it into the publishable state. To do this navigate to your workflow located under the folder at the path ‘/sitecore/system/Workflows‘ find the Workflow State, in this example Review.
In the new Workflow Commands add set both Next State fields to be the publishable State, e.g. Approved. For the ‘Approve with Test‘ Command set the Appearance Evaluator Type field to be the following class;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sitecore.ContentTesting.Workflows.TestCandidatesCommandStateEvaluator, Sitecore.ContentTesting |
For the ‘Approve without Test‘ Workflow command add the following class to it’s Appearance Evaluator Type to the below
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sitecore.ContentTesting.Workflows.TestCandidatesCommandNameEvaluator, Sitecore.ContentTesting |
This is the Workflow we are aiming to achieve.
Workflow Actions
Now to wire-up the Test Editor so its displayed to the user when the Command ‘Approve with Test‘ is called. Right click on the ‘Approve with Test‘ Command click Insert from Template and choose the new Worfklow Action ‘Launch Create Test Dialog Action‘ located at the path ‘/sitecore/templates/System/Analytics/Testing/Workflow/Launch Create Test Dialog Action‘. The Action requires the following type in the Type string field;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sitecore.ContentTesting.Workflows.LaunchCreateTestDialogAction, Sitecore.ContentTesting |
A useful feature on this Action is the checkbox which will create a Suggested Test for the user is the wizard can not be displayed. This will use Sitecore’s automated testing to run tests it has determined to have the potential to add value to the Site.
Finally, for the ‘Approve without Test‘ State, create a Worfklow Action to delete any tests that may exist for the Item. Sitecore will handle this all for you by basing the Workflow Action on the ‘Template Remove Tests‘ Action located at the path ‘/sitecore/templates/System/Analytics/Testing/Workflow/Remove Tests Action‘ and the Type string field to be the value below. It is also worth using the delete the Test Definition to make your Test Lab clean of unwanted Tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sitecore.ContentTesting.Workflows.RemoveTestsAction, Sitecore.ContentTesting |
The outcome of all your hard work will be displayed in the Workflow Chunk of the Review Tab will give the option to Approve with or without testing.
And that’s it!
That is all you have to do to enable Content Testing!
Get your Content Editors Testing what they are editing without a big change to their process. They can use your lovely new workflow to test the colour of that button they love so much.
Hi Jonathan,
Thank you for the post it was helpful 🙂
I am having an issue with the “preview and start test” popup is coming up with a blank screen. And the Start and Cancel button doesn’t do anything.
Any help on this would be really appreciated.
Thanks,
Soni
LikeLike
Hi Soni,
What does the logs say? If you open Development tools in chrome what response code is coming back for the request to display the pop-up?
Many thanks,
Jonathan
LikeLike
Hi Jonathan,
Thank you very much for your reply. I can see all the response code are coming back with 200 when I do a hard refresh but I noticed a javascript error in the console. Couldn’t see anything in the sitecore logs relating to the same. Does this js error suggest something?
Uncaught TypeError: Cannot read property ‘initialize’ of undefined
at child.addBehavior (sitecore-1.0.2.js:855)
at sitecore-1.0.2.js:605
at Array.forEach ()
at Function._.each._.forEach (underscore.1.4.4.js:78)
at child.views.View (sitecore-1.0.2.js:604)
at child [as constructor] (sitecore-1.0.2.js:209)
at child [as constructor] (sitecore-1.0.2.js:209)
at new child (sitecore-1.0.2.js:209)
at exposedComponent (sitecore-1.0.2.js:2581)
at HTMLDivElement. (sitecore-1.0.2.js:2694)
Thank you,
Soni
LikeLike
Hi Jonathan,
This issue is fixed. Apparently the presentation components of the popup were not properly setup. We were provided a raw value for that item from sitecore support. Once we replaced it worked fine.
Thank you,
Nimesh
LikeLike
Thank you for this article. I couldn’t find these templates in my sitecore 8 instance:
/sitecore/templates/System/Analytics/Testing/Workflow/Remove Tests Action‘
/sitecore/templates/System/Analytics/Testing/Workflow/Launch Create Test Dialog Action
But I could find these below. Are they the same thing?
/sitecore/templates/System/Content Testing/Workflow/Remove Tests Action
/sitecore/templates/System/Content Testing/Workflow/Launch Create Test Dialog Action
LikeLike
Thank you!
LikeLike
No problem! Happy the post helped you out 🙂
LikeLike
Pingback: Sitecore 8 Content Testing – Creating Multivariate and AB Tests | Exercising Sitecore