Skip to content

Creating new generic events

Overview

In Giosg Reporting we make use of different types of reporting events. One of those events is the most flexible and easiest to use for internal and external developers alike, this is the Generic Event. We have internal systems that apply aggregations over these events so these can be used to count, or average over a specific time when requested through Giosg APIs.

What does a generic event look like

In Giosg Reporting we have the a notion of generic event, this is an event that can be used for :

Name Required Type Description
event_version Yes Int Event version
vendor Yes String Vendor of event
source Yes String Source of event, either "trusted" or "untrusted"
category Yes String Event category
label Yes String Event label
action Yes String Event action
organization_id Yes String Owner organization UUID
properties No Array<String> List of string properties describing event
dim1 No String Custom dimension
dim2 No String Custom dimension
dim3 No String Custom dimension
dim4 No String Custom dimension
dim5 No String Custom dimension
visitor_id No String Giosg visitor identifier
session_id No String Giosg visitor session identifier
user_id No String Giosg user id (UUID)
browser_name No String Visitor browser name
browser_version No String Visitor browser version number
device_screen_height No String Visitor screen height
device_screen_width No String Visitor screen width
device_type No String Visitor device type
geo_city No String Visitor city
geo_country No String Visitor country
ip_organization No String Visitor company or name of the ISP
os_name No String Visitor operating system
os_version No String Visitor operating system version

How can we send this generic event to giosg

We can use many of these fields in the generic event to fill in information that we might need in the future, or we want to use in giosg systems. Please keep in mind that not all of the above fields are required, you can mix and match the fields that you need. Below you will find two simple implementations in Python or JavaScript.

 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
import requests

GIOSG_SERVICE_BASE_URL = "https://api.giosg.com"
organization_id = "<your_organization_uuid>"

event = {
    "events": [
        {
            "event_version": 1,
            "organization_id": organization_id,
            "vendor": "com.company.system",
            "category": "event",
            "action": "",
            "label": "",
            "properties": [],
            "value": 1,
            "visitor_id": "<unique visitor ID>"
        }
    ]
}


def send_event_to_generic_reporting(event):
    response = requests.post(
        "{}/events/v2/store/external".format(GIOSG_SERVICE_BASE_URL),
    json=event)
    response.raise_for_status()
    return response.json()

send_event_to_generic_reporting(event)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const GIOSG_SERVICE_URL = "https://api.giosg.com/events/v2/store/external";
const organization_id = "<your_organization_uuid>"
const EVENT = {
    "events": [
        {
            "event_version": 1,
            "organization_id": organization_id,
            "vendor": "com.company.system",
            "category": "event",
            "action": "",
            "label": "",
            "properties": [],
            "value": 1,
            "visitor_id": "<unique visitor ID>"
        }
    ]
}

fetch(GIOSG_SERVICE_URL, {
    method: "POST",
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify(EVENT)
}).then(result => console.log("Request complete. Return Value: ", result))

Once the events are posted to giosg's systems we can go ahead and fetch data back from giosg's systems.

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

Request body:

 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
    const GIOSG_SERVICE_URL = "https://service.giosg.com/api/events/v2/orgs/<organization_id>/fetch";
    const organization_id = "<your_organization_uuid>"
    const json = {
        "sources":[
            "trusted",
            "untrusted"
        ],
        "interval":{
            "start":"2021-11-26T00:00:00.000+02:00",
            "end":"2022-02-08T23:59:59.999+02:00",
            "time_zone":"Europe/Helsinki"
        },
        "granularity": "all",
        "group_by": [],
        "organization_id": organization_id,
        "vendor": "com.giosg.system",
        "aggregations": [],
        "filters":{
            "type":"and",
            "fields":[
                {
                    "type":"selector",
                    "dimension":"category",
                    "value":"event"
                }
            ]
        }
    }

    fetch(GIOSG_SERVICE_URL, {
        method: "GET",
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify(json)
    }).then(result => console.log("Request complete. Return Value: ", result))

Once you've executed it, you will get an aggregation of all metrics that have been sent by you!

Conclusion

When you have set up sending data to Giosg Reporting System, you can now use the generic reporting and the Conversational reporting. Enjoy your new reporting.

Endpoints used in this tutorial

  1. https://api.giosg.com/events/v2/store/external
  2. https://service.giosg.com/api/events/v2/orgs/<organization_id>/fetch