# 062. Returning and new visitor behavior

**Question:** Do recorded visitor types differ in purchase conversion and product engagement?

## Result

The largest computed metric is 0.2491 for New_Visitor; the smallest is 0.1393 for Returning_Visitor. Metric: rate (Purchase-session share).

Visitor labels do not identify individual customers or lifetime value.

![Returning and new visitor behavior](outputs/chart.png)

| visitortype | events | n | rate | wilson_lower | wilson_upper | median_product_pages | median_product_seconds |
| --- | --- | --- | --- | --- | --- | --- | --- |
| New_Visitor | 422 | 1694 | 0.2491 | 0.2291 | 0.2703 | 13 | 414.2 |
| Other | 16 | 85 | 0.1882 | 0.1193 | 0.2841 | 5 | 136.5 |
| Returning_Visitor | 1470 | 10551 | 0.1393 | 0.1328 | 0.1461 | 19 | 655.5 |

The chart shows 3 of 3 result rows; the table previews the first 3 in the analysis-defined order. [Download the full result table](outputs/results.csv). Numerical values are computed from the source; missing results stay unavailable.

## Method

Conversion intervals joined to median product-page engagement.

The study uses shared source preparation and reusable statistical routines. Its specific transformations are in [analysis.py](analysis.py), and common model/evaluation code is in [portfolio/methods.py](../../portfolio/methods.py). The [notebook](analysis.ipynb) executes the study and displays the saved results.

## Decision and limitations

Separate retention and acquisition hypotheses before designing an experiment.

One observation is a completed session. End-of-session behavior cannot support an early-session prediction claim. PageValues is excluded from purchase models because it can encode downstream purchase information. Associations are not experiment results. 

Related studies may share observations or holdouts. These are focused analytical studies, not independent replications or deployed business systems. Any model refinements informed by these results need new untouched evaluation data. No commercial impact is inferred from an association or backtest.

## Reproduce

From the repository root, after installing `requirements.txt`:

```powershell
python projects/062-returning-and-new-visitor-behavior/analysis.py
```

Source data are downloaded automatically if absent. Original archives are retained unchanged and checked by SHA-256. The cleaned cache normalizes column names; field-specific changes are visible in [data preparation](../../portfolio/data.py). Runtime evidence is in [receipt.json](outputs/receipt.json).

## Source

[Online Shoppers Purchasing Intention](https://archive.ics.uci.edu/dataset/468/online+shoppers+purchasing+intention+dataset), Sakar and Kastro (2018). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/shoppers.json) and [prepared-data audit](../../data/provenance/shoppers_prepared.json) record the downloaded files, field coverage and hashes.
