Session Stream

Making Use of Session Stream Data

Once you have access to Session Stream files, you need an automated way to consume these files.

Reading Session Stream Files

After you download the files, you must parse the data into in-memory objects. You can use the following example Python script as a basic starting point.

Example Script to Parse Session Stream Files


Now you can transform and load the data into a database, use it to drive application code, join Monetate data with your own data for further analysis, and more. See Session Data Description in the Monetate Knowledge Base for the detailed structure of the data object.

Using Session Stream Data with a BI Platform

If your BI platform accepts JSON files as a data source, you can load Session Stream files as is. You may need to decompress the JSON files first. Consult your platform's documentation to determine if it supports JSON files and to learn how to load data.

Due to the volume of data involved, Monetate highly recommends loading Session Stream data into a database first. You can then configure the database as a data source in your BI platform. Most BI platforms better support connecting to databases rather than loading JSON files.

The session JSON structure contains nested data. For this reason you should split the data into several tables if you plan to use a relational database. Consult your database's documentation, your database administrator, and Session Data Description in the Monetate Knowledge Base for guidance on designing the table structure.

Creating the Database Schema

The following schema is an example of a MySQL database without metadata.

Example MySQL Database Without Metadata


Loading the Data

The following example script demonstrates how to load data into the tables created using the schema in the previous section.

While it's not a requirement for using Session Stream, you need MySQL Connector/Python to run this example script.

Example Code to Load Monetate Session Stream Data


If your site receives a large amount of traffic, your dataset may be too large for this type of script to process in a reasonable amount of time. In that case, use specialized Extract, Transform, Load (ETL) tools for better throughput.

Connecting with a BI Platform

Once you store the data in a database, you can configure it as a data source in your platform. Consult the platform's documentation and support resources for how to do this.

The following example demonstrates how to use Session Stream data for analysis in Tableau Desktop.

First, create a new workbook in Tableau. Select the MySQL data source, and then fill in the connection details.

The MySQL modal in the Tableau Desktop application


In the Database section on the left sidebar of the Data Source panel, select the database (synonymous with "schema" in MySQL) that contains your Session Stream data tables.

The Database selector expanded in Tableau Desktop


Drag the tables from the left sidebar to the main panel.

The Tableau Desktop application, with a list of tables in the left sidebar and the 'Drag tables here' message in the main panel


Set up a left-join between the main Sessions table and the four auxiliary tables containing nested data.

The Tableau Desktop application, with multiple tables joined in the main panel


Build queries and analytics with your data.

The Tableau Desktop application, with a map of the US eastern seaboard dotted with a multitude of points representing data


You may need to convert some Measures to Dimensions and vice versa in the Data pane in the left sidebar to more accurately characterize the fields.