适用于 Google Analytics(分析)4 的 Google Analytics(分析)Measurement Protocol 可通过 HTTP 请求直接将事件发送到 Google Analytics(分析)服务器,从而增强对网站和应用数据流的衡量。您可以记录服务器与服务器之间以及线下发生的互动情况,并将其作为 Measurement Protocol 事件发送给 Google Analytics(分析),以便显示在报告中。
您必须使用代码植入(gtag、跟踪代码管理器或 Google Analytics for Firebase),才能使用 Measurement Protocol。请参阅主要功能部分,了解有关 Measurement Protocol 如何与 Google Analytics(分析)4 搭配使用的重要信息。
使用情形
下面是使用 Measurement Protocol 的一些方式:
将线上和线下行为联系起来。
衡量客户端和服务器端的互动。
发送在标准用户互动之外发生的事件,例如线下转化。
发送来自无法使用自动收集功能的设备和应用(如自助服务终端、手表)的事件。
开始使用
请参阅发送事件,了解如何使用 Measurement Protocol 将事件发送到 Google Analytics(分析)。
[null,null,["最后更新时间 (UTC):2024-04-22。"],[[["\u003cp\u003eThe Google Analytics Measurement Protocol allows you to send data directly to Google Analytics servers, enabling measurement of server-to-server, offline, and other interactions not captured by standard tagging methods.\u003c/p\u003e\n"],["\u003cp\u003eIt's primarily designed to supplement, not replace, data collection through gtag.js, Google Tag Manager, and Google Analytics for Firebase.\u003c/p\u003e\n"],["\u003cp\u003eYou can leverage the Measurement Protocol for use cases such as tying online and offline behavior, measuring interactions across various touchpoints, and capturing data from devices where automatic collection isn't feasible.\u003c/p\u003e\n"],["\u003cp\u003eTo fully utilize the features of the Measurement Protocol and access comprehensive reporting, it's essential to implement tagging using gtag.js, Google Tag Manager, or Google Analytics for Firebase.\u003c/p\u003e\n"],["\u003cp\u003eThe protocol respects user privacy settings and automatically joins data with online interactions to apply preferences for personalized ads and ad tracking limitations.\u003c/p\u003e\n"]]],["The Google Analytics Measurement Protocol sends events directly to Google Analytics servers via HTTP requests, augmenting existing data collection methods like gtag and Firebase. It enables recording server-to-server and offline interactions, such as tying online to offline behavior, measuring diverse interactions, and sending events from unsupported devices. Using tagging is mandatory and essential for its functionality. The protocol automatically joins online and offline data for privacy settings and utilizes existing geographic/device information for reporting.\n"],null,["# Measurement Protocol\n\nThe Google Analytics Measurement Protocol enhances measurement for web and app\nstreams by [sending events](/analytics/devguides/collection/protocol/ga4/sending-events) directly to Google Analytics servers in\nHTTP requests. You can record server-to-server and offline interactions, and\nsend them as Measurement Protocol events to Google Analytics, where they can be\nviewed in [reports](/analytics/devguides/reporting/data/v1/basics).\n| **Key Point:** The intent of the Measurement Protocol is to augment automatic collection through gtag, Tag Manager, and Google Analytics for Firebase, not to replace it.\n\nYou must use tagging (gTag, Tag Manager, or Google Analytics for Firebase) to\nuse this protocol. See [key features](#key_features) for important information\non how this Measurement Protocol works with Google Analytics.\n\nUse cases\n---------\n\nHere are some ways to use the Measurement Protocol:\n\n- Tie online to offline behavior.\n- Measure client-side and server-side interactions.\n- Send events that happen outside standard user-interaction, like offline conversions.\n- Send events from devices and apps where automatic collection isn't available, like kiosks and watches.\n\nRead more about how to implement common use cases in the [use cases guide](/analytics/devguides/collection/protocol/ga4/use-cases).\n\nGet started\n-----------\n\nSee [send events](/analytics/devguides/collection/protocol/ga4/sending-events) to learn how to send events to Google Analytics using the\nMeasurement Protocol.\n\nIf you're implementing the Measurement Protocol for an app stream, you can start\nwith the [Send app events to Google Analytics using Measurement Protocol](//firebase.google.com/codelabs/firebase_mp)\ncodelab.\n\nArchitecture\n------------\n\nHere is an overview of the Measurement Protocol.\n\nKey features\n------------\n\nThis section explains important information for using the Measurement Protocol.\nYou must use gTag, Tag Manager, or Google Analytics for Firebase for tagging to\nuse most of the Measurement Protocol features with Google Analytics.\n\n### Remarketing\n\nSame device remarketing is supported when [Google signals](//support.google.com/analytics/answer/9445345) is turned on. For\ncross-device remarketing, a User ID is required.\n\n### Advertising identifiers\n\nAdvertising identifiers such as GBRAID/WBRAID collected during online\ninteractions are automatically joined with Measurement Protocol events using `client_id`\nor `app_instance_id`.\n\n### Privacy settings\n\nMeasurement Protocol events are joined with online interactions using\n`client_id` or `app_instance_id` to functionally adopt user privacy settings\nsuch as \"non personalized ads\" and \"limit ad tracking\".\n\n### Geographic and device information\n\nGoogle Analytics automatically joins the most recent geographic and device\ninformation from tagging with Measurement Protocol events using `client_id` or\n`app_instance_id`. This ensures that your Measurement Protocol events are reflected in\nreports that include geographic and device dimensions.\n\nIf you want a Measurement Protocol event to reflect geographic and device information\nfrom a *specific* session instead of the latest information for the `client_id`\nor `app_instance_id`, then include `session_id` in the event and send it to\nMeasurement Protocol within 24 hours of the start of the session.\n\nYou can provide [geographic information](/analytics/devguides/collection/protocol/ga4/reference#payload_geo_info) and [device information](/analytics/devguides/collection/protocol/ga4/reference#payload_device_info) for events\nusing the Measurement Protocol.\n\nIf device information isn't collected by your tag, it defaults to\n`desktop` for Web streams, and `mobile` for App streams.\n\n### Full server-to-server\n\nWhile it's possible to send events to Google Analytics solely with the\nMeasurement Protocol, only partial reporting may be available. The purpose of the\nMeasurement Protocol is to augment existing events collected using gtag, GTM, or\nFirebase. Some event and parameter names are [reserved](/analytics/devguides/collection/protocol/ga4/reference?#reserved_names) for use through\nautomatic collection and cannot be sent through the Measurement Protocol.\n\n### Generate or rename events\n\nRules for [generating or renaming\nevents](//support.google.com/analytics/answer/10085872) aren't triggered by\nevents sent with the Measurement Protocol. Your application should implement the logic\nto send custom events through the Measurement Protocol, similar to the rules configured\nin the Google Analytics UI.\n\nNext steps\n----------\n\n- Learn how to [send events](/analytics/devguides/collection/protocol/ga4/sending-events) using the Measurement Protocol.\n- Validate your event payloads using the [Measurement Protocol validation\n server](/analytics/devguides/collection/protocol/ga4/validating-events).\n- Check out the [protocol](/analytics/devguides/collection/protocol/ga4/reference) and [event](/analytics/devguides/collection/protocol/ga4/reference/events) reference.\n\n| **Note:** All applications that use the Measurement Protocol must follow the [protocol policy](/analytics/devguides/collection/protocol/ga4/policy)"]]