# Draft: Chat Performance Reporting
## Purpose and Use
Performance reports are purposely built to deliver timely summary data to a workspace owner or administrator. Ideally, the resulting data will be portable enough to be included in automated weekly and/or monthly emails and to quickly display on the user app dashboard.
It is also a goal to display the organizations performance vs a benchmark performance (e.g. all of Rake users or eventually users in a similar business vertical or geographic region).
## What is Chat Performance?
The KPIs that help illuminate how effective an organizations enagagement and messaging campaigns are performing are as follows:
#### Chat KPIs
* Engagement Ratio (e.g. Chats completed to Website visits)
* Response time (e.g. Agent responsiveness to inbound messages from visitors)
* Missed Chats (e.g. Chats started and ended without any agent response = a missed chat)
* Session Duration (e.g. how quickly conversations are completed is a measure of efficiency and the faster it is usually means happy customers)
> * Chat Rating ##future## (e.g. after a chat the visitor rates the experience 1-5 stars)
## Report Mockup

https://app.moqups.com/X5N8BeibSJ/view/page/a9051634a
#### Date Filters
* By Date Group - Rake Benchmarking Statistics will only work for specific date groups (See below for complete list, e.g. Last Month, Last Week, Yesterday, etc.)
* By Custom Date Range - Benchmark statistics would NOT be included for custom range
#### Event Filters
* all
* rakeLiveChatUrlTrakingId
## Tracking specific URLs
Allow administrative users to define a list of pages (urls) they specifically want to track. Other pages visited in a session will still be tracked but grouped together as "*Other*".
#### Collection: rakeLiveChat_Bots.tracking
This collection will define the urls to track and give them a freindly name.
```
RakeLiveChat_Bots: {
tracking: [
{ type: 'urls', url: 'mycompany.com/sales', rakeLiveChatUrlTrakingId: 1, friendlyName: "sales", rakeLiveChatTrakingTypeIds: [1,2] },
{ type: 'urls', url: 'mycompany.com/suports', rakeLiveChatUrlTrakingId: 2, friendlyName: "support" },
{ type: 'urls', url: 'mycompany.com/checkout', rakeLiveChatUrlTrakingId: 3, friendlyName: "checkout" },
]
}
```
If the url is not defined with a trackingId in the above list, it will be included in a "catch-all" grouping on the report, maybe like "other pages". It will be marked as "-1".
> rakeLiveChatUrlTrakingId: -1, -- if not found rakeLiveChatUrlTrakingId in tracking
>
Update after 01.21
```
{
trackId: 56,
urls: [
mycompany.com/gifts/
*.mycompany.com/cards/*
mycompany.com/stuffed-animals/*
],
label: 'Gift shop'
},
{
trackId: 57,
urls: [
*.mycompany.com/*
],
label: 'All'
},
{
trackId: 57,
urls: [
mycompany.com/gifts/
],
label: 'Gifts'
}
```
##### Remove trackId record
We need to ask: "Are you sure you want to delete this tracking url? Any previous statistics related specifically to this URL will be removed."
change in collection trackingId => -1
###### Urls
- Allow wildcard
- Not allow full equals urls
-------
## Tracking Specific Actions/Events
Our reporting will focus on the following types of actions and events that help build the KPIs discussed above. These will be defined in the collection with name: rakeLiveChatTrackingTypes
#### Collection: rakeLiveChatTrackingTypes
```
examples:
{
rakeLiveChatTrakingTypeId: 1, name: 'Session with reply from Agent'
},
{
rakeLiveChatTrakingTypeId: 2, name: 'Session without reply from Agent'
},
{
rakeLiveChatTrakingTypeId: 3, name: 'Visits'
},
{
rakeLiveChatTrakingTypeId: 4, name: 'Response Time'
},
{
rakeLiveChatTrakingTypeId: 5, name: 'First response Time'
},
{
rakeLiveChatTrakingTypeId: 6, name: 'Session Duration'
},
```
#### TrackingId's
| Id | Versions |Name | Description | When does this insert |
| -- | ---| ---- | -- | --|
| 0 | 1.4.10 | Website Visit | A web browser session| When widget loads and a new session is created |
| 1 | | Messages | A message was sent by either entity| When chat session ends |
| 2 | 1.4.10 | Chat Session | A session ended with an agent reply| When chat session ends |
| 3 | 1.4.10 | Missed Chat | A session ended with no agent messages| When chat session ends |
| 4 | |Average Response Time | Difference between date/time (in seconds) of date/time of message from initiatingEntity and the response from the secondaryEntity in a session | When chat session ends |
| 5 | 1.4.10 | First Reponse Time | Difference between date/time (in seconds) of date/time of FIRST message from initiatingEntity (visitor) and the FIRST response from the secondaryEntity (Agent) in a session | When chat session ends |
| 6 | 1.4.10 | Session Duration | Total duration of session (in seconds). | When chat session ends |
-------
## Rake Benchmark Statistics
It is helpful to display performance benchmarks, the mean, of common web and chat KPIs. These should always be presented in terms of mean values across an aggregate of bots. Storing and displaying ONLY aggregated and mean performance will improve performace and avoid accidental exposure of a single bot/enterprise.
#### Website Visits & Chats
For example if we had just three bots in Rake:
| Bot Name | Visits | Sessions w/Engagement | Missed Chats | Avg Duration (sec) | Engagement% | Missed% |
| --- | ------ | --------------------- | ------------ | -------- |-- |------- |
|bot1 - abcxyz.com | 1000 | 50 | 10 |350 | .05 |.01 |
|bot2 - mycompany.com | 2000 | 200 | 50 |800 |.1 |.025 |
|bot3 - bigcompany.com | 15000 | 1000 | 250 |350 |.067 |.0167 |
| System Summary | Visits | Sessions w/Engagement | Missed Chats |Avg Duration (sec)| Engagement% | Missed% |
| --- | ------ | --------------------- | ------------ | -------- |--| ------- |
|aggregate & mean values| 18000| 1250 | 310 |500 |.0723 |.0172 |
> **ONLY** the aggregate & mean calculated values in the System Summary table above would saved to the **system_Statistics** collection for their **reportingDateGroups**
#### Collection: statistics_DateGroups
This collection would create the friendly name to display on reporting date parameters in our apps, and establish a schedule to which chron jobs in the system will run to aggregate this data. In order to provide instant access to Benchmarking statistics, only these date ranges will support Benchmarking data.
```
{ reportDateGroupId: 0, reportDateGroupName: "Last year", chronJobSchedule: "Yearly @ Jan 1, 12:00:00 AM"},
{ reportDateGroupId: 1, reportDateGroupName: "Year to date", chronJobSchedule: "Daily @ 12:00:00 AM"},
{ reportDateGroupId: 2, reportDateGroupName: "Last month", chronJobSchedule: "Monthly @ 1st Day of Month @ 12:00:00 AM"},
{ reportDateGroupId: 3, reportDateGroupName: "Month to date", chronJobSchedule: "Daily @ 12:00:00 AM"},
{ reportDateGroupId: 4, reportDateGroupName: "Last week", chronJobSchedule: "Weekly @ DOW=1 @ 12:00:00 AM"},
{ reportDateGroupId: 5, reportDateGroupName: "Week to date", chronJobSchedule: "Daily @ 12:00:00 AM"},
{ reportDateGroupId: 6, reportDateGroupName: "Yesterday", chronJobSchedule: "Daily @ 12:00:00 AM"},
{ reportDateGroupId: 7, reportDateGroupName: "Today", chronJobSchedule: "Hourly @ 12:00:00 AM"},
```
> Response time must save response off all message
> !!Research how other calc repsonse time of sessions
```
{
hours: 11,
count: {
sessions: 56,
messages: { fromAgent: 56, fromUser: 75 }
},
engagement:[
{ rakeLiveChatTrakingTypeId: 1, count: 12, value: this.count/this.countSessions },
{
rakeLiveChatTrakingTypeId: 2,
count: 13,
value: this.count/this.countSessions
},
{
rakeLiveChatTrakingTypeId: 6,
totalResponseTimes: 21312ms,
value: this.totalResponseTimes/this.count.messages
},
...
]
}
{
hours: 12,
countSessions: 56,
engagement:[
{
rakeLiveChatTrakingTypeId: 1,
count: 12,
value: this.count/this.countSessions
},
{
rakeLiveChatTrakingTypeId: 2,
count: 13,
value: this.count/this.countSessions
},
...
]
},
{
hours: 13, // now
countSessions: 57,
engagement:[
{ rakeLiveChatTrakingTypeId: 1, count: 12 },
{ rakeLiveChatTrakingTypeId: 2, count: 14 },
...
]
}
```
vs
```
{
botId: 245
date: '1/27/2020 14:00',
trackingTypeId: 1,
totalSessions: 45,
value: 12
},
{
date: '1/27/2020 14:00',
trackingTypeId: 2,
totalSessions: 45,
value: 878
}
```
#### Collection: statistics_System
This collection will be updated by the chron jobs in correspondance to the dateGroupIDs from *statistics_DateGroups*
```
{ reportDateGroupId: 0, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // last year
{ reportDateGroupId: 1, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // year to date
{ reportDateGroupId: 2, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // last month
{ reportDateGroupId: 3, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // month to date
{ reportDateGroupId: 4, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // last week
{ reportDateGroupId: 5, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // week to date
{ reportDateGroupId: 6, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // yesterday
{ reportDateGroupId: 7, avgResponse: 522, engagementRatio: 0.15, avgSessionDurationSecs: 305.2} // today
```
---
> Another thought was to have groupings like this so you can compare current month to last year same month, or today to Last Wednesday. **This is NOT needed for MVP**
```
{ lastJanuary: { avgResponse: 522, engagementRatio: 0.15 } //2019
{ lastFebruary: { avgResponse: 522, engagementRatio: 0.15 }
...
{ lastMonday: { avgResponse: 522, engagementRatio: 0.15 } }
{ last... }
```
Description:
* System benchmark statistics are not available on custom date ranges
-------
## Example Data
#### Collection: statistics_rakeLiveChatBots
```
{
sesionId:56,
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: 1,
"createdAt" : ISODate("2020-01-13T16:55:45.909+02:00") // important for per hours
datetime: {
minute: 55,
hours: 16,
day: 13
month: 1
year:2020
}
"rakeLiveChatTrakingTypeId: 1,
},
{
sesionId:5556,
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: 1,
"createdAt" : ISODate("2020-01-13T16:50:45.909+02:00") // important for per hours
"rakeLiveChatTrakingTypeId: 1,
},
{
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: 3,
"createdAt" : ISODate("2020-01-13T16:55:45.909+02:00") // important for per hours
"rakeLiveChatTrakingTypeId: 3,
value: 56
},
{
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: 3,
"createdAt" : ISODate("2020-01-13T17:55:45.909+02:00") // important for per hours
"rakeLiveChatTrakingTypeId: 3,
value: 20
},
{
sesionId:57,
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: 2,
rakeLiveChatTrakingTypeId: 2,
"createdAt" : ISODate("2020-01-13T16:02:53.683+02:00")
},
{
sesionId: 5778,
rakeLiveChatBotId: 45,
rakeLiveChatUrlTrakingId: -1,
rakeLiveChatTrakingTypeId: 2,
"createdAt" : ISODate("2020-01-13T16:02:53.683+02:00")
},
```
#### Collection schema:
##### statistics_rakeLiveChatBots
```{
sesionId,
rakeLiveChatBotId,
rakeLiveChatUrlTrakingId,
createdAt : ISODate("2020-01-13T16:55:45.909+02:00"),
rakeLiveChatTrakingTypeId
},
```
##### statistics_System
```
{
reportDateGroupId, // ? maybe we can expand count of these Ids
totalSessions,
engagement:[
{ rakeLiveChatTrakingTypeId: 1, count: 12 },
{ rakeLiveChatTrakingTypeId: 2, count: 13 },
...
]
totalDuration,
}
```
##### rakeLiveChat_TrackingTypes
```{
rakeLiveChatTrakingTypeId,
name
},
```
## After dicsuss 01.17
### DB schema
#### Statistics tracking types
Collection name: statisticsTrackingTypes
Schema:
```
{
statisticsTrackingTypeId: Number;
name: String,
}
```
Examples: ***TODO add all tracks from [Draft: Chat Performance Reporting.TrackingId’s](/OGCMSi1XS8ObGhJDHso7Qw#TrackingId’s)***
```
{ statisticsTrackingTypeId: 3, name: 'Total sesisons count' },
{ statisticsTrackingTypeId: 2, name: 'Session without reply' },
{ statisticsTrackingTypeId: 4, name: 'Session with reply' },
{ statisticsTrackingTypeId: 5, name: 'Count of visitors' },
```
#### System Statistics
Collection name: system_Statistics
Schema:
```
{
createdAt: DateTime;
statisticsTrackingTypeId: Number,
value?: number,
platfomrId: Number,
botId: Number,
}
```
Examples:
```
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 3, // Total sesisons count
value: 580,
platfomrId: 4, // RakeLiveChat
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 2, // Session without reply
rakeLiveChatURLTrackingId: 22, // /helps
value: 13,
platfomrId: 4, // RakeLiveChat
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 4, // Session with reply
rakeLiveChatURLTrackingId: 22, // /helps
value: 567,
platfomrId: 4, // RakeLiveChat
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 5, // Visitors
rakeLiveChatURLTrackingId: 22, // /helps
value: 567,
platfomrId: 4, // RakeLiveChat
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 4, // Session with reply
rakeLiveChatURLTrackingId: 24, // /supports
value: 567,
platfomrId: 4, // RakeLiveChat
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 4, // Session without reply
value: 12,
platfomrId: 3, // Facebook
botId: 4
},
{
createdAt: '1/27/2020 14:00',
statisticsTrackingTypeId: 4, // Session with reply
value: 567,
platfomrId: 3, // Facebook
botId: 4
},
```
#### Rake live chat sessions
Collection name: RakeLiveChat_Sessions
Schema:
```
{}
```
Examples: **TODO add description**
```
{
sessionId: 56,
rakeLiveChatURLTrackingId: 22
date: '1/27/2020 14:00',
}
```