Skip to content

Fetching information from User Chat Statistics

Overview

Giosg platform provides APIs for fetching metrics from the chats the users within your organization had. This tutorial guides you through requesting the basic metrics the User Chat Statistics provides you, for use in your own application.

Prerequisites

A guide on how to create an API token can be found here

Once you have obtained your API token(s), define the Authorization HTTP header for all your API requests:

1
Authorization: Token <api_key>

You should replace the <api_key> with your API token

Remember that the api token is connected to the user that created the token, which means that if the user is deleted the api token will also be invalidated. You can create an extra user and create the token with this user, remember to name the user so that it doesn’t get deleted by mistake e.g “Reporting api-user do not delete”

Which metrics can I request?

Giosg has multiple Reporting metrics that are used in the User Chat Statistics dashboard, these are:

All of these metrics are available for customers and developers to make use of. These metrics may have different scopes, this means that the result of the query sent will be broken down based on the scope selected. For instance: When requesting a User scope you will get results broken down in User UUIDs which you can connect the metric to specific users within your organization.

Queries

Real chats

At least 1 message from the visitor and 2 messages from the user, excluding autosuggests

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
"interval": {
    "start": "2020-10-29T00:00:00.000+02:00",
    "end": "2020-10-30T23:59:59.999+02:00",
    "time_zone": "Europe/Helsinki"
},
"granularity": "day",
"group_by": [],
"aggregations": [
    {
        "type": "count",
        "fields": [
            "chat_session_id"
        ]
    }
],
"filters": {
    "type": "and",
    "fields": [
        {
            "type": "or",
            "fields": [
                { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                { "type": "selector", "dimension": "chat_type", "value": "external" }
            ]
        },
        { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
        { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
        {
            "type": "selector",
            "dimension": "scope",
            "value": "org"
        }
    ]
}
}

def get_real_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Messages in real chats

Amount of user messages in real chats (chat had at least 1 message from visitor and 2 messages from user, excluding autosuggests)

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["user_message_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["user_message_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["user_message_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["user_message_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}

def get_messages_in_real_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Short chats

Chats where user has participated but haven't qualified as a real chat.

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [
    ],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            {
                "type": "or",
                "fields": [
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "lower": 1,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "upper": 1,
                                "lower": 0,
                                "upperStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    },
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "upper": 2,
                                "lower": 1,
                                "upperStrict": true,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "lower": 0,
                                "lowerStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    }
                ]
            },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "bound",
                "dimension":"user_message_count",
                "lower": "2",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "bound",
                "dimension":"visitor_message_count",
                "lower": "1",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [
        "team_id"
    ],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            {
                "type": "or",
                "fields": [
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "lower": 1,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "upper": 1,
                                "lower": 0,
                                "upperStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    },
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "upper": 2,
                                "lower": 1,
                                "upperStrict": true,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "lower": 0,
                                "lowerStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    }
                ]
            },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "bound",
                "dimension":"user_message_count",
                "lower": "2",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "bound",
                "dimension":"visitor_message_count",
                "lower": "1",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [
        "user_id"
    ],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            {
                "type": "or",
                "fields": [
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "lower": 1,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "upper": 1,
                                "lower": 0,
                                "upperStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    },
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "upper": 2,
                                "lower": 1,
                                "upperStrict": true,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "lower": 0,
                                "lowerStrict": true,
                                "ordering": "numeric"
                            }
                        ]
                    }
                ]
            },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "bound",
                "dimension":"user_message_count",
                "lower": "2",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "bound",
                "dimension":"visitor_message_count",
                "lower": "1",
                "lowerStrict": false,
                "ordering": "numeric"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            }
        ]
    }
}

How to request this metric (example)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "count",
            "fields": [
                "chat_session_id"
            ]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            {
                "type": "or",
                "fields": [
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "lower": 1,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "upper": 1,
                                "lower": 0,
                                "upperStrict": True,
                                "ordering": "numeric"
                            }
                        ]
                    },
                    {
                        "type": "and",
                        "fields": [
                            {
                                "type": "bound",
                                "dimension": "user_message_count",
                                "upper": 2,
                                "lower": 1,
                                "upperStrict": True,
                                "ordering": "numeric"
                            },
                            {
                                "type": "bound",
                                "dimension": "visitor_message_count",
                                "lower": 0,
                                "lowerStrict": True,
                                "ordering": "numeric"
                            }
                        ]
                    }
                ]
            },
            {
                "type": "bound",
                "dimension":"user_message_count",
                "lower": "2",
                "lowerStrict": False,
                "ordering": "numeric"
            },
            {
                "type": "bound",
                "dimension":"visitor_message_count",
                "lower": "1",
                "lowerStrict": False,
                "ordering": "numeric"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}

def get_short_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Average first response wait time

How long on average did it take for the users to reply to the visitor who started chatting

Request URL: POST https://api.giosg.com/api/events/v2/orgs/<organization_id>/fetch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_first_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": ["user_id"],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_first_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_first_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}

def get_average_first_response_wait_time_metric():
    response = requests.post("{}/api/events/v2/orgs/{}/fetch".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Average reponse wait time

How long on average were the visitors waiting for reply to their messages

Request URL: POST https://api.giosg.com/api/events/v2/orgs/<organization_id>/fetch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": ["user_id"],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["avg"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_session_response_wait_time"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"changed"
                }
            ]
    }
}

def get_first_response_wait_time_metric():
    response = requests.post("{}/api/events/v2/orgs/{}/fetch".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

average invite accepted wait time

The average invite accepted wait time. This is the metric to show the average wait time for accepting an invitation.

Request URL: POST https://api.giosg.com/api/reporting/workflow/v1/orgs/<organization_id>/query/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
    {
        "avg": ["dim1"],
        "where": [
            {
                "field": "category",
                "search": "track_chat_invite",
            },
            {
                "field": "action",
                "search": "chat_invitation_accepted",
            },
            {
                "field": "partner_organization_ids",
                "search": "",
            },
        ],
        "timespan": {
            "After": "2020-10-29T00:00:00.000+02:00",
            "Before": "2020-10-30T23:59:59.999+02:00",
        },
    }

average first message sent

The average first message sent. This is the metric to show the average time of first message sent in a chat.

Request URL: POST https://api.giosg.com/api/reporting/workflow/v1/orgs/<organization_id>/query/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
    {
        "avg": ["dim1"],
        "where": [
            {
                "field": "category",
                "search": "track_chat_invite",
            },
            {
                "field": "action",
                "search": "first_message_sent",
            },
            {
                "field": "partner_organization_ids",
                "search": "",
            },
        ],
        "timespan": {
            "After": "2020-10-29T00:00:00.000+02:00",
            "Before": "2020-10-30T23:59:59.999+02:00",
        },
    }

Real chats with sales

Real chats that had sales. These carts were purchased during the chats or max 24 hours after.

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "count",
            "fields": ["chat_session_id"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "count",
            "fields": ["chat_session_id"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "count",
            "fields": ["chat_session_id"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "count",
            "fields": ["chat_session_id"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

def get_real_chats_with_sales_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Purchases in real chats

Number of purchases made by visitors who had a real chat (chat had at least 1 message from visitor and 2 messages from user, excluding autosuggests)

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["order_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["order_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["order_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["order_count"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

def get_purchases_in_real_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Sales in real chats

Sales in real chats (chat had at least 1 message from visitor and 2 messages from user, excluding autosuggests)

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "sum",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            }
        ]
    }
}

def get_sales_in_real_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Average purchase value in real chats

Average purchase value per visitor who had a real chat (chat had at least 1 message from visitor and 2 messages from user, excluding autosuggests)

Request URL: POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "avg",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["team_id"],
    "aggregations": [
        {
            "type": "avg",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "team"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": ["user_id"],
    "aggregations": [
        {
            "type": "avg",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "user"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "interval": {
        "start": "2020-10-29T00:00:00.000+02:00",
        "end": "2020-10-30T23:59:59.999+02:00",
        "time_zone": "Europe/Helsinki"
    },
    "granularity": "day",
    "group_by": [],
    "aggregations": [
        {
            "type": "avg",
            "fields": ["sales"]
        }
    ],
    "filters": {
        "type": "and",
        "fields": [
            {
                "type": "or",
                "fields": [
                    { "type": "selector", "dimension": "chat_type", "value": "visitor" },
                    { "type": "selector", "dimension": "chat_type", "value": "external" }
                ]
            },
            { "type": "bound", "dimension": "user_message_count", "lower": 2, "ordering": "numeric" },
            { "type": "bound", "dimension": "visitor_message_count", "lower": 1, "ordering": "numeric" },
            {
                "type": "selector",
                "dimension": "room_ids",
                "value": "<room_id_here>"
            },
            {
                "type": "selector",
                "dimension": "scope",
                "value": "org"
            },
            { "type": "bound", "dimension": "order_count", "lower": 0, "lowerStrict": true, "ordering": "numeric" }
        ]
    }
}

def get_average_purchase_value_in_real_chats_metric():
    response = requests.post("{}/api/reporting/v1/orgs/{}/chat_sessions".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Chat invitations

Amount of user invites to other users to participate in real chats.

Request URL: POST https://api.giosg.com/api/events/v2/orgs/<organization_id>/fetch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_invitation"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": ["user_id"],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_invitation"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_invitation"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}

def get_chat_invitations_metric():
    response = requests.post("{}/api/events/v2/orgs/{}/fetch".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Bot Clicks

Amount of clicks a visitor has generated of a bot sending an attachment.

Request URL: POST https://api.giosg.com/api/events/v2/orgs/<organization_id>/fetch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_message_attachment_click_action"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": ["user_id"],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_message_attachment_click_action"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}

How to request this metric (example)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
token = "<giosg account token>"
organization_id = "<uuid>"

json = {
    "sources": ["trusted"],
    "interval": {
            "start":"2020-12-01T00:00:00.000+02:00",
            "end":"2020-12-31T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
    },
    "granularity":"all",
    "group_by": [],
    "organization_id": "<organization_id>",
    "vendor":"com.giosg.chat",
    "aggregations":["count"],
    "filters": {
            "type":"and",
            "fields": [
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"chat_message_attachment_click_action"
                },
                {
                    "type":"selector",
                    "dimension":"action",
                    "value":"created"
                }
            ]
    }
}

def get_bot_clicks_metric():
    response = requests.post("{}/api/events/v2/orgs/{}/fetch".format(GIOSG_SERVICE_BASE_URL, organization_id), headers={'Authorization': 'Token ' + token}, json=json)
    response.raise_for_status()
    return response.json()

Conclusion

In this tutorial we have learnt how to request information from Giosg Reporting, and got some metrics that can be used further by your own IT in your own products or reports.

Endpoints used in this tutorial

  1. https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions
  2. https://api.giosg.com/api/events/v2/orgs/<organization_id>/fetch