2

I am using Sitecore 9.0.2, I am using a custom Update Contact submit action in forms to update facet in xDB. Now before updating contact in xDB, I want to check that if user is Robot or not, so for that I have checked Sitecore.Analytics.Pipelines.CommitSession.Robots processor, it is using ContactClassification.IsRobot function and passing if args.Session.Contact.System.Classification parameter. Below is code:

public class Robots : CommitSessionProcessor
{
    public override void Process(CommitSessionPipelineArgs args)
    {
        Assert.ArgumentNotNull(args, "args");
        Assert.IsNotNull(args.Session.Contact, "args.Context.Contact should not be null");
        if (ContactClassification.IsRobot(args.Session.Contact.System.Classification) && AnalyticsSettings.Robots.IgnoreRobots)
        {
            ContactManager expr_58 = Assert.ResultNotNull<ContactManager>(Factory.CreateObject("tracking/contactManager", true) as ContactManager);
            expr_58.SaveContactToCollectionDb(args.Session.Contact);
            expr_58.RemoveFromSession(args.Session.Contact.ContactId);
            Log.Debug("[Analytics]: The CommitSession pipeline was aborted. Visit was classified as robot and visits made by robots are configured to be ignored.", this);
            args.AbortPipeline();
        }
    }
}
<processor type="Sitecore.Analytics.Pipelines.CommitSession.Robots, Sitecore.Analytics" patch:source="Sitecore.Analytics.Tracking.Database.config"/>

I am trying to use same function on UpdateContact but I am not sure what parameter I need to pass in IsRobot function. Below is my submit action:

public class UpdateContact : SubmitActionBase<UpdateContactData>
{

    public UpdateContact(ISubmitActionData submitActionData) : base(submitActionData)
    {
    }

    protected override bool Execute(UpdateContactData data, FormSubmitContext formSubmitContext)
    {
    }
}

Can anybody suggest me what parameter I need to pass instead of args.Session.Contact.System.Classification?

3

You still need to send the Classification stored on the current Contact, but how you get it is a little different:

if (Tracker.Current?.Session?.Contact?.System != null)
{
    ContactClassification.IsRobot(Tracker.Current.Session.Contact.System.Classification)
}

This will get the current session's contact and use that classification.

Further reading: how a visitor is classified as a robot

https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/robot-detection-overview.html

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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