3

We are migrating Sitecore 7 instances to Sitecore 8 and we currently have the following scenario in production.

enter image description here

Different sites with two separate CMs and CDs (failover) each using the same databases (Core, Master, Web). Each site has its own solution and use different assemblies which are conflicting between sites. So that's why they are hosted in separated CM servers. Also, they are under different domains (e.g. site1.nl, site2.nl) and therefore don't share the same session.

Our client wants to start using xDB and leverage data collect from different sites. e.g. personalize content in Site 1 based on interactions done in Site 2.

We were wondering if keeping this same architecture would enable the users to use xDB features across multiple sites. If not, could you please point us to a best alternative?

Update

This information has just arrived. All the sites are under the same domain. They use different subdomains, though. e.g. coffee.gohorse.nl, ontdek.gohorse.nl and etc. So I believe we won't need to implement custom code to share the session between the sites.

I've noticed that Sitecore 7 creates 1 cookie named SC_ANALYTICS_SESSION_COOKIE and another named SC_ANALYTICS_GLOBAL_COOKIE. The cookie value SC_ANALYTICS_SESSION_COOKIE changes per subdomain, but the SC_ANALYTICS_GLOBAL_COOKIE remains the same (and expires 10 years from now).

We are planning to use an out of process session management with Redis in Sitecore.

That being said, I want to know if personalization with xDb data across multiple sites would be possible?

1
  • From my point of view, if all the CD servers make use of the same mongoDB and reporting database, users across different sites will be able to have contents from the different sites Mar 6, 2018 at 10:32

2 Answers 2

3

I don't know the way how to do it out of the box. But can suggest how to do it with hack. Idea is to sync cookies that Sitecore uses to identify visitor to same values across all websites.(Important requirement is that analytics DB and Sessions store should be shared between all sites). When these cookies will be same, Sitecore would think that it is the same visitor.

You can add bunch of invisible service iframes that will set ASP.NET_SessionId, SC_ANALYTICS_GLOBAL_COOKIE and SC_ANALYTICS_SESSION_COOKIE to same values for all your websites.

Example of action that will get cookie values:

public ActionResult CookiesIFrame()
{
    var urlReferrer = System.Web.HttpContext.Current.Request.UrlReferrer;

    //If user opens website first time or comes from other website
    if (urlReferrer == null || [urlReferrer does not contain any of your websites])
    {
        var aspNetSessionId = HttpContext.Current.Request.Cookies["ASP.NET_SessionId"];
        var scAnalyticsGlobalCookie = HttpContext.Current.Request.Cookies["SC_ANALYTICS_GLOBAL_COOKIE"];
        var scAnalyticsSessionCookie = HttpContext.Current.Request.Cookies["SC_ANALYTICS_SESSION_COOKIE"];

        var model = new CookiesViewModel()
            {
                AspNetSessionId = aspNetSessionId,
                ScAnalyticsGlobalCookie = scAnalyticsGlobalCookie,
                ScAnalyticsSessionCookie = scAnalyticsSessionCookie
            };

        //Render iframe with transfered parameters
        return View(model);
    }
    return new EmptyResult();
}

public class RegionCookiesViewModel
{
    public string AspNetSessionId { get; set; }
    public string ScAnalyticsGlobalCookie { get; set; }
    public string ScAnalyticsSessionCookie { get; set; }
}

View that will render Iframes:

@model RegionCookiesViewModel

@{ 
    var iFrameUrl = String.Format("/api/sitecore/crossdomainmanagement/setcookies?AspNetSessionId={0}&ScAnalyticsGlobalCookie={1}&ScAnalyticsSessionCookie={2}", Model.AspNetSessionId, Model.ScAnalyticsGlobalCookie, Model.ScAnalyticsSessionCookie);
}
@foreach(site in yourWebsites(without current one)){
    <iframe src="@Html.Raw(site + iFrameUrl)" style="display:none;"></iframe>
}

Then you will be able to set these cookie values in SetCookies action:

public ActionResult SetCookies(CookiesViewModel model)
{
    HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId") { Value = model.AspNetSessionId })
    HttpContext.Current.Response.Cookies.Add(new HttpCookie("SC_ANALYTICS_GLOBAL_COOKIE") { Value = model.ScAnalyticsGlobalCookie })
    HttpContext.Current.Response.Cookies.Add(new HttpCookie("SC_ANALYTICS_SESSION_COOKIE") { Value = model.ScAnalyticsSessionCookie })
    return new EmptyResult();
}

Another one idea, how to achieve personalization across your websites is to use Federated Experience Manager. But it will require a lot and complex configuration of your items...

Update(according addition to question): As all sites will be on same domain and will have different subdomains then it should be enough to configure setting of cookies

<configuration>
  <system.web>
    <httpCookies domain=".gohorse.nl" />
  </system.web>
</configuration>

No needs to create custom solution described above.

2
  • Nice. Still do you think there will be a problem with the data that xDB collects if we follow this architecture? I wonder if somehow reporting will get messy.
    – João Neto
    Mar 6, 2018 at 11:17
  • @JoãoNeto To be honest I have tried this approach only with sharing of session. ("ASP.NET_SessionId" cookie). We have personalization rules based on session values. It works fine for our solution. I assume that reporting should work, I don't foresee any issues. But can't promise it, because I haven't tried it...
    – Anton
    Mar 6, 2018 at 12:14
2

João, Anton's solution is the kind of SSO-like that I told you during the hackathon.

Despite being very unusual to have SC instances sharing the same database but having different DLLs, I believe you will be able to setup all instances to point to the same xDB (mongo), then all sites will start to track down accesses individually. Later, if you want to use the analytics data from one site into the another, you will need some kind of backward identification - either by using the hack that Anton described, or doing the same form identification method that we used at the hackathon.

Just pay attention that OOTB you must have 1 and only 1 processing server, you still can scale it, but by default only 1 is allowed.

1
  • One server with processing role is indeed needed. Make sure here that this server is aware of all sites for which it needs to aggregate data, regardless of whether these sites are deployed to this server or not.
    – Joost
    Mar 12, 2018 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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