A data pipeline and model of session-level conversion in a seasonal e-commerce category: SQL for data preparation, R for imputation and logistic regression. Written for the course Data Engineering for MADS (MSc Marketing Analytics & Data Science, University of Groningen, 2026).
The project used data from an e-commerce retailer under a non-disclosure agreement. Data, schemas, brand names and business results are not included; the code is shared to show the method.
Raw event logs were turned into one row per session in PostgreSQL:
- time variables (weekend, time of day) and browsing variables (number of distinct product categories viewed);
- a brand familiarity score per session, computed from past purchases with window functions (
OVER(),DATE_TRUNC); - joins of the event, article and customer tables into a single enriched session table.
The session data was then combined with external weather and search-trend data.
- Missing demographic and device data imputed with multiple imputation by chained equations (MICE: predictive mean matching and polytomous regression).
- Multivariate outliers detected with the Mahalanobis distance.
- Chi-square tests for associations between categorical variables.
- Logistic regression on conversion, with multicollinearity checked through VIF.
- Predicted probability plots with 95% confidence intervals in ggplot2.
The business results are confidential. At a general level:
- behavioural variables, such as browsing variety and brand familiarity, predicted conversion better than demographics;
- the difference between mobile and desktop could be quantified, which helps decide where to improve the user experience;
- weather variables such as sunshine and temperature were useful secondary controls in this seasonal category.
code/data_pipeline.sql session-level data preparation
code/conversion_analysis.R imputation, outlier checks and logistic regression
R packages: tidyverse, mice, lubridate, car, broom, scales.