Get Session Data

Introduced in SDK v2.1.0

What this does (purpose)

Returns a JSON snapshot of the current app/session context that you can log, persist, or forward to your analytics pipeline. Useful for debugging attribution, personalising screens, or attaching metadata to your own events.

Note: The Capacitor plugin returns the payload as a JSON string inside an nv key. Parse it with JSON.parse() before use.

Method

NotifyVisitors.getSessionData().then((value)=> {
    // do your work here
});
NotifyVisitors.getSessionData().then((value: any)=> {
    // do your work here
});

Typical usage (log the payload)

NotifyVisitors.getSessionData().then((value)=> {
    const sessionData = JSON.parse(value.nv);
    console.log("Session Data = ", sessionData);
});
NotifyVisitors.getSessionData().then((value: any)=> {
    const sessionData = JSON.parse(value.nv);
    console.log("Session Data = ", sessionData);
});

Raw response (JSON string)

{
  "nv":"{\"utm\":{\"source\":\"google-play\",\"campaign\":\"(not set)\",\"medium\":\"organic\",\"keyword\":\"\",\"content\":\"(not set)\",\"google_click_id\":\"\"},\"session\":{\"session_id\":\"sPdEuB6Nzl3VZ1DqMlOhxlbqm7DaxQe2JzjH9cvCo7ArR1Rz7c\",\"session_count\":\"3\",\"user_type\":\"Unknown\",\"visit_type\":\"returning\"},\"location\":{\"country\":\"India\",\"city\":\"Aligarh\",\"region_code\":\"36\",\"continent_code\":\"AS\"},\"device\":{\"manufacturer\":\"Google\",\"model\":\"sdk_gphone64_x86_64\",\"carrier\":\"T-Mobile\",\"network_type\":\"WIFI\",\"wifi_enabled\":true,\"bluetooth_enabled\":\"Enabled\"},\"app\":{\"google_analytics_id\":\"bd4d1b45-5ded-42bd-93b6-8159b2a8091d\",\"ios_ifa\":\"\",\"screen_name\":\"MainActivity\",\"sdk_version\":\"5.6.0\"}}"
}

Parsed response

After converting the JSON string with JSON.parse(value.nv):

{
  "utm": {
    "source":"google-play",
    "campaign":"(not set)",
    "medium":"organic",
    "keyword":"",
    "content":"(not set)",
    "google_click_id":""
  },
  "session": {
    "session_id":"sPdEuB6Nzl3VZ1DqMlOhxlbqm7DaxQe2JzjH9cvCo7ArR1Rz7c",
    "session_count":"3",
    "user_type":"Unknown",
    "visit_type":"returning"
  },
  "location": {
    "country":"India",
    "city":"Aligarh",
    "region_code":"36",
    "continent_code":"AS"
  },
  "device": {
    "manufacturer":"Google",
    "model":"sdk_gphone64_x86_64",
    "carrier":"T-Mobile",
    "network_type":"WIFI",
    "wifi_enabled":true,
    "bluetooth_enabled":"Enabled"
  },
  "app": {
    "google_analytics_id":"bd4d1b45-5ded-42bd-93b6-8159b2a8091d",
    "ios_ifa":"",
    "screen_name":"MainActivity",
    "sdk_version":"5.6.0"
  }
}