1

I am running 2 Sitecore CD servers, the servers are load balanced on Azure and we have Azure CDN as well.

The strange thing is that 2 lines of codes are randomly missing from the page response we get back from the CDN.

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

I have checked through about 30 unique page load on the CDN and made sure that the X-Cache:Hit is not in the response. About 60% of the pages were missing the 2 lines of code. These 2 lines were generated by @Html.Sitecore().VisitorIdentification().

My initial thought was that perhaps one of the two CD servers is acting weird. But I tried loading 30 pages each on both CD servers, both CD servers return a perfect response 100% of the time without anything missing. Both CD servers also have an identical layout.aspx with @Html.Sitecore().VisitorIdentification() in the Head section as well.

So, I am guessing it is related to the Azure CDN.

Does anyone have experience with this? Please help.

2
  • Do you serve Sitecore pages via CDN?
    – Marek Musielak
    Commented Mar 14, 2019 at 6:27
  • Yeah, the Sitecore pages are served through the CDN. Commented Mar 14, 2019 at 6:52

1 Answer 1

3

You should never server Sitecore pages through CDN.

  1. Sitecore VisitorIdentification rendering generates a link to VisitorIdentification.js file only for the first user request. Then the cookies are set already so it's not needed to include js file anymore.

If your CDN serves cached page without VisitorIdentification.js none of the new contacts will have js rendered and they may not be identified properly.

  1. Sitecore personalizes content based on custom conditions (if your content authors use that functionality).

If your CDN serves cached page which was generated for User A, it doesn't mean that the same page with same components should be served for User B.

  1. Sitecore gives you ability for Multivariate Testing - if you serve pages via CDN, it will never work cause Sitecore is never hit.

So to summarize:

VisitorIdentification.js is missing randomly depending on whether someone's initial request was cached (with js) or someone's 2nd or later request was cached.

You can read more:

2
  • Thank you for the answer, really helpful. Like to confirm my understanding, so Sitecore stores all interaction data within the user's session, which the data captured are subsequently stored in XDB when the session expires. This is why it is important that the page requests reaches the origin server. As for VisitorIdentification.js, it is Sitecore's way of Identifying whether the user is a robot or a normal user and VisitorIdentification itself does not perform capturing of any analytics data. Commented Mar 14, 2019 at 9:47
  • I wasn't able to find any resource which says "VisitorIdentification is for robot detection only". I believe some of the internal mechanisms may be executed only when user is recognized as 'not a robot'. And http session can be cleared if request is considered as coming from robot. Offical Sitecore docs say: "always include @Html.Sitecore().VisitorIdentification() in your layout. I would stick with that
    – Marek Musielak
    Commented Mar 14, 2019 at 10:19

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.