2

We are using Sitecore 10.1.3 with SXA.

The default SxaLayout.cshtml has the line @Html.Sxa().VisitorIdentification().

When I check the view source of any page in our DEV environment, the following lines are missing.

<meta name="VIcurrentDateTime" content="638374437286915946" />
<meta name="VirtualFolder" content="/" />
<script type="text/javascript" src="/layouts/system/VisitorIdentification.js"></script>

But they are rendered in the PRD site.

Are any config settings missing in DEV?

1
  • If you check /sitecore/admin/showconfig.aspx does your DEV environment has Xdb.Enabled and Xdb.Tracking.Enabled both set to true?
    – Marek Musielak
    Commented Dec 7, 2023 at 6:52

1 Answer 1

1

If you check /layouts/system/visitoridentification.ascx control is a condition that has to be true then only it renders the VisitorIdentification.js.

<%@ Control Language="c#" AutoEventWireup="true" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<%  if (Sitecore.Context.Diagnostics.Tracing || Sitecore.Context.Diagnostics.Profiling)
    {%>
<!-- Visitor identification is disabled because debugging is active. -->
<%
    }
    else if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Core.ContactClassification.IsAutoDetectedRobot(Sitecore.Analytics.Tracker.Current.Session.Contact.System.Classification))
    {
      string virtualFolder = "";
      if (Sitecore.Context.Site != null)
      {
        virtualFolder = Sitecore.Context.Site.VirtualFolder;
      }
%>
<meta name="VIcurrentDateTime" content="<%: DateTime.UtcNow.Ticks %>" />
<meta name="VirtualFolder" content="<%: virtualFolder %>" />
<script type="text/javascript" src="/layouts/system/VisitorIdentification.js"></script>
<%
    }
%>


As per condition if the Tracker is active and the VisitorClasification == 925 (Bot - Auto-detected) then the VisitorIdentification.js will be added.

If you want to check quickly, follow the below steps.

  1. Go to \layouts\System\VIChecker.aspx file
  2. Add <% Tracker.Current.Session.SetClassification(925, 925, true); %>.
  3. Open a new incognito browser and load the site.
  4. View page source from the browser to validate it.

Reference: Visitor identification using the robot detection component

Hope it helps!

2
  • I have added that code in VIchecker.aspx and there is o change in the page. The visitoridentificaton.js still doesn't render. What should I be expecting from your suggestion.
    – sukesh
    Commented Dec 7, 2023 at 6:12
  • Those steps are just to validate the condition works fine. The VisitorIdentification control only outputs the blocking Javascript once - at the initial stage where the system has "auto detected a robot". Once it is satisfied that the session is not a robot, it outputs blank content. Check these links for more details. sitecore.stackexchange.com/questions/7385/… sitecore.stackexchange.com/questions/17430/… Commented Dec 7, 2023 at 6:32

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