REPOSITORY CODING · MEDIUM
Include touches exactly at the attribution lookback boundary
The temporal join excludes a touch exactly lookback seconds before conversion. Restore the inclusive lower bound while retaining user equality, the conversion-time upper bound and as-of visibility.
Data EngineerClickstream attribution laboratory
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
PySpark · 55 minute session
- Attribute bounded offline conversions to eligible campaign touches using real PySpark joins, windows and aggregation. Each immutable touch/conversion ID is globally unique within its collection; exact redelivery is ignored and conflicting redelivery is invalid. Validate all supplied records before applying snapshot visibility.
- A record is visible when observed<=asOf. An eligible touch belongs to the same user and lies in the closed event-time interval [conversion.at-lookback,conversion.at]. First and last models choose the corresponding timestamp, with lexical smallest touch ID breaking equal-time ties.
- The linear model allocates whole cents equally across distinct eligible campaigns, not exposure rows. Integer quotient shares are followed by remainder cents in lexical campaign order. Zero-cent shares remain visible. An unmatched conversion receives its complete value in the reserved (direct) bucket.
- Return conversions by ID with campaign credits sorted lexically, campaign totals in lexical order and valueTotal from deduplicated visible conversions. Credit totals must equal visible conversion value exactly; no conversion can be dropped by the attribution join.
- Inputs are limited to 200 touches and 100 conversions, with bounded identifiers and integer timestamps/values. Observed cannot precede event time. The local Spark process is reused; no advertising platform, account or external database is contacted.