The Attribution Pipeline is designed to process customer journey data, calculate customer interaction phases (IHC), and generate channel performance reports. This report outlines the pipeline's functionality, key steps, and recent enhancements.
-
Database Connection:
- Connects to the SQLite database (
challenge.db).
- Connects to the SQLite database (
-
Data Fetching:
- Retrieves data from the following tables:
session_sources(session events)conversions(conversion events)session_costs(marketing costs)
- Retrieves data from the following tables:
-
Customer Journey Construction:
- Builds customer journeys by linking sessions to conversions based on user IDs and timestamps.
-
API Integration:
- Sends customer journeys to the IHC Attribution API in chunks of 100.
- Receives IHC values and stores them in the
attribution_customer_journeytable.
-
Channel Reporting Calculation:
- Aggregates data into the
channel_reportingtable, calculating:- Cost: Sum of session costs
- IHC: Sum of IHC values
- IHC Revenue: Sum of IHC multiplied by conversion revenue
- Aggregates data into the
-
Filtering by Date Range (Optional):
- If a date range is provided, the pipeline processes only sessions and conversions within the range.
- If no date is given, it defaults to processing all available data.
-
Exporting Results:
- Exports channel performance data to
channel_reporting.csv. - Calculates key metrics:
- CPO (Cost Per Order):
cost / ihc - ROAS (Return on Ad Spend):
ihc_revenue / cost
- CPO (Cost Per Order):
- Exports channel performance data to
- Date Range Filtering:
- Users can now specify a date range via
start_dateandend_date. - This allows for targeted analysis over specific time periods.
- Users can now specify a date range via
- Fallback to Full Data:
- If no date range is provided, the pipeline defaults to processing all data without filtering.
The pipeline efficiently processes customer journeys, calculates key attribution metrics, and produces actionable channel reports. The addition of date range filtering increases flexibility for time-specific analyses.