As datasource we are using a redshift db, that currently only stores data for this test experiment we have 2 tables:
• sessions - this table stores the user sessions that have seen the page we want to track, and also stores which variant was served
• conversions - this table stores successful conversions, together with a session_id which is the same one we have in the sessions table
sessions table create statement:
CREATE TABLE sessions (
session_id INT PRIMARY KEY,
user_id INT,
timestamp TIMESTAMP,
page_name VARCHAR(255),
experiment_variant VARCHAR(50)
);
user_id
is an optional field only populated with logged in users, but we also support conversion for “guest” users in which case it would be null
conversions table create statement:
CREATE TABLE conversions (
conversion_id INT PRIMARY KEY,
user_id INT,
session_id INT,
timestamp TIMESTAMP
);
based on these 2 tables we have also setup 2 key metrics:
_*page_sessions*_ which uses the following query:
SELECT
session_id as user_id,
timestamp as timestamp
FROM
sessions
conversions which uses the following query:
SELECT
session_id as user_id,
timestamp as timestamp
FROM
conversions