Search code examples
c#asp.netsitecoresitecore6sitecore-dms

How to add a new visitortag to the current user (Sitecore)?


I'm using Sitecore 6.6. I want to add a new visitortag to the current user in programcode (C#). Does anyone know how to do this?

Thanks a lot.

Jordy


Solution

  • You can assign tags to the current analytics visitor through the Analytics API:

    Sitecore.Analytics.Tracker.Visitor.Tags.Add("MyTagName", "content of my tag");
    

    To debug, you can check the VisitorTags table in the Analytics database but keep in mind that it might take a few moments until the tags are saved down to the database as Analytics saves them asynchronously.

    Also keep in mind that Analytics is disabled during editing mode.