If we wanted to provide data (get/set operations on content tree, analytics, personalization, tracking data) from Sitecore 9 to native mobile apps (not based on Sitecore Mobile SDK and Xamarin but created using IOS swift and Android java) , in this case Sitecore 9 item web service and XConnect can be utilized or XConnect with JSS can be utilized?

As per inputs from JSS slack channel Layout service can helpful but:

If user accessing the different-2 pages from mobile and in one of the page, one rendering having personalization based on Goal or User persona (Profile card) then Layout service will return personalized content for that page?

How to push tracking data for personalization ( which cookies value needs to be set from app) from native mobile app?

Please let me know, what are the ways or recommended approach to share data (content, analytics, personalization, tracking) from Sitecore 9 to native mobile apps.

up vote 4 down vote accepted

In my point of view, JSS is pretty suite for your requirements. I've implemented something like you want with Xamarin. But I think it doesn't matter with which technology to do that because I didn't use any Xamarin Sitecore specific frameworks or tools. I only send simple HTTP requests to LayoutService.

If user accessing the different-2 pages from mobile and in one of the page, one rendering having personalization based on Goal or User persona (Profile card) then Layout service will return personalized content for that page?

Yes, Layout Service returns the data with applied personalization rules.

How to push tracking data for personalization ( which cookies value needs to be set from app) from native mobile app?

Actually there are a few things that you need to take into account:

  • You need to pass "tracking=true" parameter for getting personalized results ({YOUR_DOMAIN}/sitecore/api/layout/render/jss?item=/&sc_lang=en&tracking=true&sc_apikey={F3A7F3C9-0D0D-4F57-8D8A-5BFCAA4C349B})
  • You need to identify user if you want to get personalized results otherwise you will receive a content as for anonymous user

I added a web service with the following method to identify contact:

public JsonResult Identify(string email)
    {
        if (email == null) throw new ArgumentNullException(nameof(email));

        Tracker.Current.Session.IdentifyAs("identification-source-name", email);

        return Json(true, JsonRequestBehavior.AllowGet);
    }

Then I send a request to this method with contact identificator (email in my case) and it returns me SC_ANALYTICS_GLOBAL_COOKIE cookie. You need to pass this cookie with all requests to JSS. It allows you to retrieve personalized content for your contact.

The following method I've used for forgetting user in case I need to change context contact:

public JsonResult ForgetCurrentContact()
    {
        if (Tracker.Current != null)
        {
            Tracker.Current.EndVisit(true);
        }

        HttpContext.Session.Abandon();

        return Json(true, JsonRequestBehavior.AllowGet);
    }
  • Great answer! Just a quick note that the tracking parameter is true by default for Layout Service requests and should only need to be passed if you want to set tracking to false. – Adam Weber Jul 20 at 11:40
  • I should also mention that you don't have to use the jss configuration for Layout Service. If the JSS JSON format doesn't suit your needs, you can create your own "named configuration" for Layout Service that will allow you to shape the JSON to align with your app. For instance, SXA has its own Layout Service named configuration. More info on named configurations can be found here: jss.sitecore.net/#/… – Adam Weber Jul 20 at 11:42
  • @AdamWeber Thank you Adam for your notes! Actually, JSS in general and the LayoutService in particular were created as tools for achieving headless principle and it is the most matching to be used for integration between Sitecoore and any native mobile app languages. It is really flexible and probably each thing can be customized. Powerful technology! Really recommended. – Artsem Prashkovich Jul 20 at 11:54
  • I agree! I'm on the team that's building JSS :) – Adam Weber Jul 20 at 12:22
  • I know :) I was in the round table session with you at SUGCON :) – Artsem Prashkovich Jul 20 at 12:24

Your Answer

 

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.