使用表格中的對應項目,將 Measurement Protocol 資料收集要求 (/mp/collect) 對應至 Data Manager API 中的 IngestEventsRequest 對等項目。
要求欄位
/mp/collect 要求 (Measurement Protocol) |
IngestEventsRequest (Data Manager API) |
附註 |
|---|---|---|
measurement_id (查詢參數) |
destinations |
網路活動的 product_destination_id 地圖。詳情請參閱「目的地欄位」。 |
firebase_app_id (查詢參數) |
destinations |
應用程式事件的 product_destination_id 對應。詳情請參閱「目的地欄位」。 |
api_secret (查詢參數) |
無對應報告 | 請參閱「設定 API 存取權」,瞭解如何在 Data Manager API 中驗證要求 |
consent |
consent |
設為 Consent 物件。 |
events |
events |
設為 Event 資源清單。詳情請參閱「事件欄位」一節。 |
client_id |
events.client_id |
網站事件的必要條件。 |
app_instance_id |
events.app_instance_id |
應用程式事件的必填欄位。 |
user_id |
events.user_id |
(選用步驟) 使用者的專屬 ID, |
timestamp_micros |
events.event_timestamp |
在 Measurement Protocol 中,這項資訊可以在要求層級或個別事件中提供。在 Data Manager API 中,沒有要求層級的時間戳記。將每個事件的 event_timestamp 設為事件發生的時間。
詳情請參閱「時間戳記格式」。 |
user_properties |
events.user_properties |
設定為 UserProperties 物件。Data Manager API 不支援為個別使用者屬性設定時間戳記。系統會根據事件的時間戳記 (event_timestamp),推斷與使用者屬性變更相關聯的時間戳記。 |
user_data |
events.user_data |
設定為 UserData 物件。詳情請參閱使用者 ID 欄位。 |
non_personalized_ads |
events.consent.ad_personalization |
如果 non_personalized_ads 是 true,請將 ad_personalization 設為 DENIED。 |
user_location |
events.event_location |
詳情請參閱「使用者位置資訊欄位」。 |
ip_override |
events.event_device_info.ip_address |
|
device |
events.event_device_info |
詳情請參閱「裝置欄位」一節。 |
user_agent |
events.event_device_info.user_agent |
|
validation_behavior |
無對應報告 | 使用「診斷」功能,在下游處理期間擷取上傳狀態,以及個別事件的錯誤和警告。如果 IngestEventsRequest 失敗 (例如缺少必填欄位),系統不會處理任何事件,您必須解決錯誤並重試要求。詳情請參閱「瞭解 API 錯誤」。 |
/debug/mp/collect |
validate_only |
將 validate_only 設為 true,即可驗證事件,但不會擷取任何資料,與 Measurement Protocol 驗證伺服器類似。 |
| 無對應報告 | encoding |
上傳 UserData 時必須提供這項資訊。設為用於 UserIdentifier 值的 Encoding。 |
目的地欄位
Measurement Protocol 會使用 measurement_id 或 firebase_app_id 查詢參數,將事件直接傳送至特定資料串流。
Data Manager API 會使用 Destination 物件指定資料傳送目的地。如要進一步瞭解目的地,請參閱「設定目的地」。
以下說明如何將 Measurement Protocol 欄位對應至 Destination 中的對等欄位:
| Measurement Protocol | Destination (Data Manager API) |
附註 |
|---|---|---|
measurement_id (查詢參數) |
product_destination_id |
設為 Google Analytics 網站資料串流的評估 ID |
firebase_app_id (查詢參數) |
product_destination_id |
設為 Google Analytics 應用程式資料串流的 Firebase 應用程式 ID |
| 無對應報告 | operating_account |
將 account_id 設為 Google Analytics 資源 ID。將 account_type 設為 GOOGLE_ANALYTICS_PROPERTY。 |
| 無對應報告 | login_account |
將 account_id 設為 Google Analytics 資源 ID。將 account_type 設為 GOOGLE_ANALYTICS_PROPERTY。 |
事件欄位
Measurement Protocol events[] |
Event (Data Manager API) |
附註 |
|---|---|---|
name |
event_name |
如果 event_name 使用預留名稱,API 會拒絕該事件並傳回 INVALID_EVENT_NAME 錯誤。 |
| 無對應報告 | event_source |
如果事件是透過網頁瀏覽器產生,請設為 WEB;如果事件是透過應用程式產生,請設為 APP。 |
| 無對應報告 | destination_references |
如果要求層級 destinations 清單包含多個 Google Analytics Destination,則為必填欄位。新增項目,指定應接收事件的目的地。 |
timestamp_micros |
event_timestamp |
詳情請參閱「時間戳記格式」。 |
params.currency |
currency |
|
params.value |
conversion_value |
|
params.customer_type |
user_properties.customer_type |
在 Measurement Protocol 中,customer_type 參數會設為事件參數。在 Data Manager API 中,請在事件的 UserProperties 物件中,於 customer_type 欄位設定。 |
params.transaction_id |
transaction_id |
部分活動和用途必須提供這項資訊。詳情請參閱「將資料轉換為 Event 物件」。 |
params.items |
cart_data.items |
詳情請參閱「購物車資料的項目欄位」一文。 |
params.coupon |
cart_data.coupon_codes |
使用 coupon_codes 欄位提供套用至購物車的優待券。請只提供 Google Analytics 的單一優待券。這與Item層級的優待券無關,後者可使用 cart_data.items.additional_item_parameters 為個別項目設定。 |
params.session_id |
additional_event_parameters |
將 parameter_name 設為 session_id 的項目地圖。 |
params.engagement_time_msec |
additional_event_parameters |
將 parameter_name 設為 engagement_time_msec 的項目地圖。 |
其他params |
additional_event_parameters |
將其他參數對應為物件清單,並使用 |
使用者 ID 欄位
Measurement Protocol user_data |
UserIdentifier (Data Manager API) |
附註 |
|---|---|---|
sha256_email_address[] |
email_address |
設為格式化並經過雜湊處理的電子郵件地址。您也可以加密雜湊電子郵件地址。 |
sha256_phone_number[] |
phone_number |
設為格式化並經過雜湊處理的電話號碼。您也可以加密雜湊電話號碼。 |
address[] |
address |
設定為 AddressInfo 物件。請遵守格式和雜湊處理規範。 |
address[].sha256_first_name |
address.given_name |
設為格式化及雜湊處理的給定名稱。您也可以加密雜湊的姓名。 |
address[].sha256_last_name |
address.family_name |
設為格式化並經過雜湊處理的家庭名稱。您也可以加密雜湊處理後的家庭名稱。 |
address[].country |
address.region_code |
|
address[].postal_code |
address.postal_code |
|
address[].city |
無對應報告 | 目前版本的 Data Manager API 不支援這項功能。 |
address[].region |
無對應報告 | 目前版本的 Data Manager API 不支援這項功能。 |
address[].sha256_street |
無對應報告 | 目前版本的 Data Manager API 不支援這項功能。 |
購物車資料的商品欄位
Measurement Protocol items[] |
Item (Data Manager API) |
附註 |
|---|---|---|
item_id |
item_id |
必要。 |
item_name |
additional_item_parameters |
將 parameter_name 設為 item_name 的項目地圖。 |
quantity |
quantity |
必要。 |
price |
unit_price |
必要。 |
| 其他項目欄位 | additional_item_parameters |
將其他商品參數 (例如 |
使用者位置欄位
Measurement Protocol user_location |
EventLocation (Data Manager API) |
附註 |
|---|---|---|
city |
city |
事件發生的城市名稱。 |
country_id |
region_code |
設為 2 個字母的 CLDR 區域代碼。 |
region_id |
subdivision_code |
設為 ISO 3166-2 子行政區代碼。 |
continent_id |
continent_code |
請設為 UN M49 格式的大陸代碼。 |
subcontinent_id |
subcontinent_code |
以 UN M49 格式設定次大陸代碼。 |
裝置欄位
Measurement Protocol device |
DeviceInfo (Data Manager API) |
附註 |
|---|---|---|
category |
category |
|
language |
language_code |
|
screen_resolution |
screen_height和screen_width |
在 Measurement Protocol 中,screen_resolution 會以字串 ("1280x720") 形式提供。在 Data Manager API 中,請將 screen_height 和 screen_width 分別以整數值傳送。 |
operating_system |
operating_system |
|
operating_system_version |
operating_system_version |
|
model |
model |
|
brand |
brand |
|
browser |
browser |
|
browser_version |
browser_version |