This is legacy documentation, and may not be complete. To see the latest documentation, if you are a marketer, refer to theMarketerssite. If you are a measurement partner, refer to theMeasurement Partnerssite.
Stay organized with collectionsSave and categorize content based on your preferences.
The Shapley value method is an algorithm that assigns credit to numerous advertising channels and touchpoints based on their modeled contribution to conversion. Using the Shapley value method, you can model the contribution that a particular channel has on conversion.
Privacy filters will remove touchpoints with fewer than 50 users and outlier users that contribute a disproportionate amount of credit to a touchpoint.
Thus, the output from the Shapley value model may be missing some touchpoints that are in the input touchpoints table.
Privacy messages are shown after each iteration of the Shapley value model. These messages include information on users and touchpoints that were filtered.
Overview of computing Shapley value values
Create the touchpoint and credit tables:
touchpoint_temp_table.
user_credit_temp_table.
Call theADH.TOUCHPOINT_ANALYSIStable-valued function using the temp tables above as arguments.
Create the touchpoint and credit tables
Create the touchpoint table
The touchpoint table is where user events related to touchpoints are defined. Example data may include, but isn't limited to:campaign_id,creative_id,placement_id, orsite_id.
The table must contain the following columns:
Column name
Type
touchpoint
string Arbitrary touchpoint name. (Must not be NULL or contain commas.)
user_id
string The id of a user who visits the touchpoint. (Must not be NULL or 0.)
event_time
int The time that the user visited the touchpoint. (Must not be NULL.)
The user credit table is where conversion events are defined.
For each user, only events with a timestamp prior to the conversion are considered.
The table must contain the following columns:
Column name
Type
user_id
string The id of a user who visits the touchpoint. (Must not be NULL or 0.)
event_time
int The time when the contribution event happened. (Must not be NULL.)
credit
integer The credit contributed by the user. It can be any credit one would like to analyze. For example, the conversion value, the number of conversions, etc. It must be between 1 and 100.
The table-valued function is a function that returns a table as a result. As such, you can query the table-valued function as you would a normal table.
The name of the client-created temp touchpoint table. The table is required to have schema which contains the columns oftouchpoint,user_id, andevent_time.
credits_tmp_table_name
The name to the client-created temp user credit table. The table is required to have schema which contains the columnsuser_id,credit, andconversion_time.
model
string Must be SHAPLEY_VALUES.
Output table
The output table will contain the following schema:
Column name
Type
touchpoint
string Touchpoint name.
score
integer Calculated Shapley value score for this touchpoint.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe Shapley value method attributes conversion credit to advertising channels based on their contribution.\u003c/p\u003e\n"],["\u003cp\u003eAds Data Hub applies a simplified Shapley value method, respecting privacy by filtering touchpoints with limited user data.\u003c/p\u003e\n"],["\u003cp\u003eTo calculate Shapley values, create touchpoint and user credit tables and utilize the \u003ccode\u003eADH.TOUCHPOINT_ANALYSIS\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003eThe touchpoint table defines user interactions with advertising touchpoints like campaign IDs, while the user credit table defines conversion events.\u003c/p\u003e\n"],["\u003cp\u003eThe output of the analysis provides a Shapley value score for each touchpoint, indicating its contribution to conversions.\u003c/p\u003e\n"]]],["The core content outlines using the Simplified Shapley Value Method in Ads Data Hub to attribute credit to advertising touchpoints. It involves creating two temporary tables: `touchpoint_temp_table` (containing user touchpoint events with columns like `touchpoint`, `user_id`, `event_time`) and `user_credit_temp_table` (containing conversion events with `user_id`, `event_time`, `credit`). These tables are then used as inputs for the `ADH.TOUCHPOINT_ANALYSIS` function to calculate Shapley values, which quantify each touchpoint's contribution to conversion. Touchpoints with fewer than 50 users may be filtered.\n"],null,["# Shapley value analysis\n\nThe Shapley value method is an algorithm that assigns credit to numerous advertising channels and touchpoints based on their modeled contribution to conversion. Using the Shapley value method, you can model the contribution that a particular channel has on conversion.\n\nAds Data Hub uses the \"Simplified Shapley Value Method\", explained in full detail in the [Shapley Value Methods for Attribution Modeling in\nOnline Advertising](https://arxiv.org/pdf/1804.05327.pdf) paper.\n| **Note:** The Shapley value model can only be used with Data Transfer-based tables: `cm_dt_*`, `dv360_dt_*`.\n\nPrivacy restrictions\n--------------------\n\nPrivacy filters will remove touchpoints with fewer than 50 users and outlier users that contribute a disproportionate amount of credit to a touchpoint. Thus, the output from the Shapley value model may be missing some touchpoints that are in the input touchpoints table.\n\n\u003cbr /\u003e\n\nPrivacy messages are shown after each iteration of the Shapley value model. These messages include information on users and touchpoints that were filtered.\n\nOverview of computing Shapley value values\n------------------------------------------\n\n1. Create the touchpoint and credit tables:\n 1. `touchpoint_temp_table`.\n 2. `user_credit_temp_table`.\n2. Call the `ADH.TOUCHPOINT_ANALYSIS` table-valued function using the temp tables above as arguments.\n\nCreate the touchpoint and credit tables\n---------------------------------------\n\n### Create the touchpoint table\n\nThe touchpoint table is where user events related to touchpoints are defined. Example data may include, but isn't limited to: `campaign_id` , `creative_id`, `placement_id`, or `site_id`.\n| **Note:** Shapley value analysis is currently limited to maximum of 150 touchpoints.\n\nThe table must contain the following columns:\n\n| Column name | Type |\n|--------------|-------------------------------------------------------------------------------|\n| `touchpoint` | `string` Arbitrary touchpoint name. (Must not be NULL or contain commas.) |\n| `user_id` | `string` The id of a user who visits the touchpoint. (Must not be NULL or 0.) |\n| `event_time` | `int` The time that the user visited the touchpoint. (Must not be NULL.) |\n\n| **Caution:** The query will fail if the total number of distinct touchpoints is greater than 150, or if a `user_id` isn't present in the `user_credit_temp_table`.\n\nSample code for creating the table: \n\n CREATE TABLE touchpoint_temp_table\n AS (\n SELECT user_id, event.event_time, CAST(event.site_id AS STRING) AS touchpoint\n FROM adh.cm_dt_impressions\n WHERE\n event.event_type IN ('VIEW')\n AND user_id \u003c\u003e '0'\n AND event.campaign_id IN UNNEST(@campaign_ids)\n\n UNION ALL\n\n SELECT\n user_id, event.event_time, CAST(event.site_id AS STRING) AS touchpoint\n FROM adh.cm_dt_clicks\n WHERE\n event.event_type IN ('CLICK')\n AND user_id \u003c\u003e '0'\n AND event.campaign_id IN UNNEST(@campaign_ids)\n );\n\n### Create the user credit table\n\nThe user credit table is where conversion events are defined.\n\nFor each user, only events with a timestamp prior to the conversion are considered.\n\n\nThe table must contain the following columns:\n\n| Column name | Type |\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `user_id` | `string` The id of a user who visits the touchpoint. (Must not be NULL or 0.) |\n| `event_time` | `int` The time when the contribution event happened. (Must not be NULL.) |\n| `credit` | `integer` The credit contributed by the user. It can be any credit one would like to analyze. For example, the conversion value, the number of conversions, etc. It must be between 1 and 100. |\n\n| **Note:** If a single user has multiple conversion events, upload them as you would any other events. Ensure that no events use a duplicative pair of `user_id` and `event_time`.\n\nSample code for creating the table: \n\n\n CREATE TABLE user_credit_temp_table AS (\n SELECT\n user_id,\n MAX(event.event_time) AS event_time,\n 1 AS credit\n FROM adh.cm_dt_activities_attributed\n WHERE user_id \u003c\u003e '0'\n AND event.campaign_id IN UNNEST(@campaign_ids)\n AND DATE(TIMESTAMP_MICROS(event.event_time)) BETWEEN @start_date AND @end_date\n AND event.activity_id IN UNNEST (@activity_ids)\n GROUP BY user_id\n );\n\nThe table-valued function\n-------------------------\n\nThe table-valued function is a function that returns a table as a result. As such, you can query the table-valued function as you would a normal table.\n\n### Syntax\n\n ADH.TOUCHPOINT_ANALYSIS(TABLE touchpoints_tmp_table_name, TABLE credits_tmp_table_name, STRING model_name)\n\n### Arguments\n\n| Name | |\n|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `touchpoints_tmp_table_name` | The name of the client-created temp touchpoint table. The table is required to have schema which contains the columns of `touchpoint`, `user_id`, and `event_time`. |\n| `credits_tmp_table_name` | The name to the client-created temp user credit table. The table is required to have schema which contains the columns `user_id`, `credit`, and `conversion_time`. |\n| `model` | `string` Must be SHAPLEY_VALUES. |\n\n### Output table\n\nThe output table will contain the following schema:\n\n| Column name | Type |\n|--------------|---------------------------------------------------------------|\n| `touchpoint` | `string` Touchpoint name. |\n| `score` | `integer` Calculated Shapley value score for this touchpoint. |\n\n### Sample code for using the table-valued function\n\n SELECT *\n FROM ADH.TOUCHPOINT_ANALYSIS(\n TABLE tmp.touchpoint_temp_table,\n TABLE tmp.user_credit_temp_table,\n 'SHAPLEY_VALUES')"]]