I want to use the layout service endpoint that is a part of jss. If I make a request to the layout service endpoint should any analytics events be triggered by default? Currently it seems that making a request directly to this endpoint does not and I'm not sure if this is due to a bad setup on my part or if this is expected behavior. I've seen a some documentation mentioning that jss supports analytics but I'm not sure if that means hitting these api endpoints record data based on the request or if it's handled in a different way.

I'm specifically looking at the experience profile to try to see when the layout service is used however new user data pertaining to the layout service endpoint does not show up. It does show up when hitting a normal front end page though. I'm using Sitecore 9 update 2.

  • Would you be able to elaborate a bit more on what you're seeing/not seeing and your environment? Layout Service requests should be tracked as interactions / visits - think of a Layout Service request for a "page" as equivalent to a normal browser visit to the same "page". – Adam Weber Jul 30 at 12:54
  • @AdamWeber absolutely. I'll update the question. – Teeknow Jul 30 at 13:50
up vote 3 down vote accepted

If you're using Experience Profile, note that by default it does not index anonymous contacts that have not been identified.

You may need to enable the <setting name="ContentSearch.Analytics.IndexAnonymousContacts" value="false"/> setting to get anonymous contacts in the Experience Profile.

Important: The above is valid for Sitecore 8.2. For 9.0, the anonymous contacts setting is different and is set on xConnect config.

Note also that analytics data is persisted on session end, which means there's a delay before it makes it to the database. Placing a abandon.aspx file with the following contents in the Sitecore webroot can allow you to arbitrarily end your session and thus flush the data immediately to xConnect:

<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
public void Page_Load(object sender, EventArgs args)
{
 Sitecore.Analytics.Tracker.Current.EndTracking();
 Session.Abandon();
}
</script>
<html>
 <body>
  <p>The session was abandoned.</p>
 </body>
</html>

FWIW, I tested direct API calls to Layout Service and they are being tracked as interactions, including attached goals in my Sitecore instance.

  • I actually threw an answer on the linked question with that difference between 8 and 9 for that setting a few days ago ;). The experience profile shows an anonymous user fine when I visit a page normally and abandon the session. It does not when I attempt to hit the page with the layout service though – Teeknow Jul 30 at 17:17
  • Do you have robot detection enabled? (JSS samples normally disable this, but JSS is not yet compatible with the robot detection API) – Kam Figy Jul 30 at 19:25
  • I redid an install and did a diff between mine and that. My global asax was not the default sitecore one. It looks like hitting the layout service and then an abandon page are making analytics show up as expected now. – Teeknow Jul 30 at 19:46

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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