0

I'm new to JSS, I need to use JSS Layout service to send personalized content to a Mobile App(API-Only Mode).

From Jss Documentation

Via Layout Service

Layout Service requests are tracked on the server-side as a 'page view' just like a traditional Sitecore site would. This includes any goals, events, etc configured to be triggered by the route item. Because Sitecore's session tracking is cookie-based, it is important to pass browser cookies to Layout Service requests (this is done by default).

Since the requests are not from a browser but from a mobile app, how to make the tracking work while requesting the layout service.

2 Answers 2

1

The Layout Service executes within the Sitecore MVC rendering engine, and thus retains all Sitecore analytics tracking and functionality. So if you use the Layout Service for routing in your JSS app, each route change will reflect as a page view in your analytics data. To avoid confusing URLs in your analytics data, the Layout Service will set the resolved item and its path as the tracked item and URL, respectively.

Layout Service exposes two actions -

  1. Getting the output of the whole layout for the item.

    /sitecore/api/layout/render/[config]?item=[path]&sc_lang=[language]&sc_apikey=[key]&tracking=[true|false]

  2. Getting the output of a particular placeholder.

    sitecore/api/layout/placeholder/[config]?placeholderName=/main&item=[path]&sc_lang=[language]&sc_apikey=[key]&tracking=[true|false]

In both actions. tracking is an optional parameter for Enables/disables analytics tracking for the Layout Service invocation with the default value true. Set the tracking parameter to false if you don't want analytics tracking for your JSS app, or for particular Layout Service calls.

1

As mentioned, Sitecore's session tracking is cookie-based, so for native/mobile apps you will need to use a HTTP client that is capable of storing cookies. For instance, if using React Native, it has some built-in support for using fetch and cookies, but with some limitations: https://facebook.github.io/react-native/docs/network

For other native dev platforms, you'll need to investigate how to implement cookie sending and storage.

1
  • Thanks for the response, I will investigate that.
    – Jojo
    Nov 5, 2019 at 12:18

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.