I am working on a feature that should behave differently based on whether or not Sitecore believes that the current Contact is legitimate or a malicious bot.

I am using ContactClassification.IsRobot(Tracker.Current.Contact.System.Classification) to determine whether the current contact has been flagged as a robot. It's been pretty easy for me to persist this Boolean value on a view model, surface it in my view, and change the behavior on the front end as a result.

The main issue I am facing is testing my feature. I would be easy for me to inject a superficial True/False value for testing purposes, however, I'm more interested in testing the feature as a true bot would see it. This begs the question: Is there a known way to have a visit flagged as a robot for testing purposes?

My goal is not to have to develop an actual malicious bot just to test my feature.

2 Answers 2


Bots are not necessarily malicious. I believe every Sitecore site in the world welcomes GoogleBot when it swings by for a visit.

For what you want to do, I suggest adding a new agent string to the Sitecore.Analytics.ExcludeRobots.config file and call up your site using same agent string.

Alternatively, in the same file, set under <excludedIPAddresses> to mark local sessions as robot per default. This, you would need to switch on and off however.

The file, on Sitecore 9, is located in \App_Config\Sitecore\Marketing.Tracking


I found another approach whereby I forego adding the VisitorIdentification() method call in my main layout when I want to pretend I am a robot. Sitecore automatically flags all traffic with a visitor identification level of 925 (IsAutoDetectedRobot) until they can prove they are human. By excluding this method call, that never happens:

@if (string.IsNullOrEmpty(Request.QueryString["sc_robot"]))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.