Tuesday, 5 November 2013

Sitecore Analytics: DMS 2.0: Persistent Cookies

Sitecore Analytics provides most accurate data as it works on server side. It has lot of tracking variables which can used for analysis.
As part of Sitecore Analytics, certain cookies are set in the web client.

SC_ANALYTICS_GLOBAL_COOKIE
SC_ANALYTICS_SESSION_COOKIE

SC_ANALYTICS_GLOBAL_COOKIE: To identify repeat visits from a single user, Sitecore sends a persistent session cookie to the web client. The name of the persistent session cookie is SC_ANALYTICS_GLOBAL_COOKIE. The persistent session cookie expires 10 years after the last page requested from the solution by the web client.

SC_ANALYTICS_SESSION_COOKIE: To identify a sequence of HTTP requests from a single user, Sitecore sends an Engagement Analytics session cookie to the web client. The name of the session cookie is SC_ANALYTICS_SESSION_COOKIE. One of key feature of Sitecore Analytics Session Cookie is though ASP.NET expires (normally due the sessionState configuration) and creates a new session in the web page, Analytics session will not expire and will not create a new visit. 

AFAIK, this expiration time cannot be changed.

In Sitecore.Analytics.dll (DMS 2.0), the below code snippets add cookies to the client. Expiration time for Global session is for 10 years. 

HttpCookie result = (current == null) ? null : current.Response.Cookies["SC_ANALYTICS_GLOBAL_COOKIE"];
if (result == null)
{
       result = new HttpCookie("SC_ANALYTICS_GLOBAL_COOKIE");
this.AddCookie(result);
}
result.Value = this.VisitorId.ToString("N");
result.Path = "/";
result.Expires = this.IsInvalid ? DateTime.UtcNow.AddDays(-1.0) : DateTime.UtcNow.AddYears(10);

In the client, 

Set-Cookie: SC_ANALYTICS_GLOBAL_COOKIE=f80224a049a94a23a6a66c5c81639e13; expires=Mon, 01-Nov-2023 20:02:52 GMT; path=/; HttpOnly
Set-Cookie: SC_ANALYTICS_SESSION_COOKIE=BEAC5C6ADBE44D9E84056B4A8C019C46|1|3i11wfogrb2aqp1h2oj5cpwr; path=/; HttpOnly

4 comments:

  1. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore | https://www.excelr.com/digital-marketing-training-in-bangalore

    ReplyDelete
  2. healthcare analytics course in hyderabad

    360DigiTMG has developed the Certification Program in Healthcare Analytics. This course is meticulously designed to suit both Healthcare practitioners, IT Business Analysts and Data Scientists.
    https://<360digitmg.com>/india/life-sciences-and-healthcare-analytics-certification-programme

    ReplyDelete

Articles

Sitecore 9.3 released!

Sitecore 9.3 has the Solr 8.1.1 support (Sitecore compatibility table is yet to be updated). SIF 2.2.0 Got a new editor - The Horizon edi...