A Python pipeline for analyzing user journeys on the Telegraph website to identify influential articles that lead to user registrations. This tool provides various attribution models to understand user behavior and content effectiveness.
-
Multiple Attribution Models:
- First Touch: Credits the first article in the user's journey
- Last Touch: Credits the last article before registration
- Linear: Distributes credit evenly across all articles
- Position-based: Assigns different weights based on article position (40% first, 40% last, 20% middle)
- Time Decay: Gives more credit to articles closer to registration
- Count: Credits each article equally
-
Data Generation:
- Synthetic data generation for testing and development
- Configurable parameters for users, articles, and registration rates
- Realistic timestamp generation
.
├── README.md
├── requirements.txt
├── src/
│ ├── __init__.py
│ └── pipeline.py
└── tests/
├── __init__.py
└─ test_pipeline.py
- Python 3.8+
- pandas
- pytest (for testing)
- Clone the repository:
git clone <repository-url>
cd telegraph-analysis- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Generate synthetic data (optional):
from src.pipeline import generate_synthetic_data
# Generate 1000 users, 50 articles, with 30% registration rate
df = generate_synthetic_data(
num_users=1000,
num_articles=50,
registration_rate=0.3,
output_path="synthetic_hitlog.csv"
)- Analyze user journeys:
from src.pipeline import analyze_user_journeys
# Analyze with time decay attribution
results = analyze_user_journeys(
"synthetic_hitlog.csv",
attribution_method="time_decay",
top_n=5
)Run the pipeline with default settings:
python src/pipeline.pyThis will:
- Generate synthetic data
- Analyze the data using the count attribution method
- Print the top 3 influential articles
Run the test suite:
pytestThe tests cover:
- Data generation
- Attribution calculations
- Journey analysis
- Edge cases and error handling
-
Count
- Counts the number of occurrences of each article in a successfully registered user journey.
-
First Touch
- Credits 100% to the first article in the journey
- Best for understanding initial user acquisition
-
Last Touch
- Credits 100% to the last article before registration
- Best for identifying final conversion drivers
-
Linear
- Distributes credit evenly across all articles
- Best for understanding overall content effectiveness
-
Position-based
- First article: 40%
- Last article: 40%
- Middle articles: 20%
- Best for understanding the importance of position
-
Time Decay
- Uses exponential decay based on position
- Later articles receive more credit
- Best for understanding recency effects