Skip to main content

Initial Contact Attribution

HardPremium

You are given the following two tables:

attribution table:

  • session_id (string): The unique identifier for a user session.
  • marketing_channel (string): The marketing channel that led to the session.
  • purchase_value (float): The monetary value of purchases made during the session.

user_sessions table:

  • session_id (string): The unique identifier for a user session (linked to attribution table).
  • ad_click_timestamp (datetime): The timestamp when the user clicked on an ad, indicating their entry into the session.
  • user_id (string): The unique identifier for the user associated with the session.

Determine the percentage of high-value customers attributed to each marketing channel based on their initial point of contact. A high-value customer is defined as a user whose total purchase value (across all sessions) exceeds 100. The initial point of contact is the user's first recorded session, based on the ad_click_timestamp.

Your output should include the following columns:

  • marketing_channel (string): The marketing channel associated with the user's first session.
  • perc_high_value (float): The percentage of high-value customers that originated from each marketing channel, relative to the total number of high-value customers.

Example output:

marketing_channelperc_high_value
Channel A0.45
Channel B0.30
Channel C0.25