Marfeel Cookies: Sharing data across subdomains

The Marfeel Javascript SDK sets up 2 first-party cookies in the publisher domain. The first one stores user information like the unique user identifier, the registered user id when provided, the first visit time, the previous visit time or the original referrer. The second one is a temporal cookie to store session information like the visit start time, referrer domain and landing page. Read more about first and third party cookies used by Marfeel.

By default the user information is tracked at the root-domain level and shared across all sub-domains. This means that a user visiting domain.com and sub.domain.com will be considered the same user, sharing all the data points like the RFV.

The default behavior can be changed specifying the domain in the cookieDomain property of the configuration object:

<script type="text/javascript">
function e(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=document.createElement("script");c.src=e,t?c.type="module":(c.async=!0,c.type="text/javascript",c.setAttribute("nomodule",""));var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(c,n)}function t(t,c,n){var a,o,r;null!==(a=t.marfeel)&&void 0!==a||(t.marfeel={}),null!==(o=(r=t.marfeel).cmd)&&void 0!==o||(r.cmd=[]),t.marfeel.config=n,t.marfeel.config.accountId=c;var i="https://sdk.mrf.io/statics";e("".concat(i,"/marfeel-sdk.js?id=").concat(c),!0),e("".concat(i,"/marfeel-sdk.es5.js?id=").concat(c),!1)}!function(e,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t(e,c,n)}(window,
/* AccountId */, {cookieDomain:'www.mywebsite.com'} /* Config */);
</script>

Important considerations

  1. All domains tracked under a same AccountId share userId when 3rd party cookies are available.
  2. When cookieDomain specifies a subdomain (i.e. en.mywebsite.com), the data is not shared with sibling domains like www.mywebsite.com, it.mywebsite.com nor the root domain (mywebsite.com).
  3. When cookieDomain specifies a root domain (i.e. mywebsite.com), the data is shared among all its subdomains (e.g. www.mywebsite.com or campaign.mywebsite.com). This is also the default behavior.

Sharing user cookie and session when third-party cookies are not available

Although Marfeel will use third-party cookies when the browser and the consent allow, some browsers don’t support third-party cookies or sandbox their usage.

Marfeel implements a method to share that information via URL when third-party cookies are not available.

User cookie should be obtained through the method getUserId() and session information with the method getSessionId() and sent as get params in the URL as mrf_u and mrf_s

window.marfeel.cmd.push(['compass', async(compass) => {
    const mrf_user = await compass.getUserId().userIdPromise;
}]);

window.marfeel.cmd.push(['compass', (compass) => {
    const mrf_session =  compass.getSessionId();
}]);