Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Measurement Protocol của Google Analytics cho phép bạn gửi dữ liệu ngoại tuyến đến luồng dữ liệu Web hoặc Ứng dụng, ngoài dữ liệu mà bạn đang thu thập bằng tính năng gắn thẻ hoặc Firebase SDK.
Hướng dẫn này mô tả các trường hợp sử dụng phổ biến của Measurement Protocol trong Google Analytics và các yêu cầu đối với những trường hợp đó.
Tóm tắt các yêu cầu
Bảng này cung cấp thông tin tham khảo nhanh về các yêu cầu cho từng trường hợp sử dụng. Hãy ghi nhớ các phương pháp hay nhất sau đây:
timestamp_micros của các sự kiện và thuộc tính người dùng mặc định là thời gian yêu cầu. Khi gửi một sự kiện hoặc thay đổi thuộc tính người dùng đã xảy ra trong quá khứ, hãy ghi đè dấu thời gian như mô tả trong hướng dẫn gửi sự kiện và hướng dẫn về thuộc tính người dùng.
Để có báo cáo Theo thời gian thực và chỉ số tương tác chính xác, hãy thêm tham số sự kiện engagement_time_msec được đặt thành số mili giây đã trôi qua kể từ sự kiện trước đó.
Trường hợp sử dụng
Mã phiên
Yêu cầu đối với thời gian yêu cầu
timestamp_micros yêu cầu
Chỉ định User-ID cho người dùng
Bắt buộc
<= kết thúc phiên là lúc bắt đầu ngày làm việc (kinh doanh)
>= bắt đầu phiên và <= kết thúc phiên
Phân bổ phiên
Bắt buộc
<= bắt đầu phiên + 24 giờ
>= bắt đầu phiên và <= kết thúc phiên
Xuất sự kiện sang các nền tảng quảng cáo
Không bắt buộc
<= ngày làm việc có phiên gần đây nhất + 63 ngày
>= thời gian yêu cầu trừ đi 2 ngày làm việc và <= thời gian yêu cầu
Gửi sự kiện hoặc thuộc tính người dùng để tạo đối tượng
Không bắt buộc
Web: <= thời gian diễn ra sự kiện trực tuyến mới nhất + 30 ngày
Ứng dụng: <= thời gian diễn ra sự kiện trực tuyến mới nhất + 42 ngày
>= thời gian yêu cầu trừ đi 2 ngày làm việc và <= thời gian yêu cầu
Chỉ định User-ID cho người dùng
Sử dụng Measurement Protocol để cung cấp sự kiện trực tuyến hoặc ngoại tuyến bằng User-ID.
Sau đây là một số ví dụ về trường hợp sử dụng để thêm User-ID vào một sự kiện:
Hoạt động đo lường trực tuyến của bạn thiếu thông tin cần thiết để tra cứu User-ID cho các sự kiện trực tuyến, nhưng bạn có một quy trình xử lý sự kiện có thể liên kết giữa một phiên trực tuyến và một User-ID.
Trong trường hợp này, bạn đang sử dụng Measurement Protocol để cung cấp các sự kiện trực tuyến có User-ID.
Bạn không có User-ID cho những sự kiện mà bạn đang gửi bằng Measurement Protocol, nhưng bạn muốn những sự kiện đó được liên kết với một User-ID nếu người dùng đã đăng nhập trực tuyến trong suốt phiên.
Trong trường hợp này, bạn đang sử dụng các sự kiện trực tuyến để cung cấp các sự kiện Measurement Protocol bằng User-ID.
Sau đây là các yêu cầu để thêm User-ID vào một sự kiện:
Thêm session_id vào danh sách thông số của sự kiện.
Gửi các sự kiện Measurement Protocol vào cùng ngày làm việc với phiên hoạt động trực tuyến.
Nếu bạn ghi đè timestamp_micros, hãy đặt giá trị này thành dấu thời gian trong khoảng thời gian bắt đầu và kết thúc của phiên trực tuyến.
Nếu mục tiêu của bạn là cung cấp User-ID cho các sự kiện trực tuyến, hãy đặt user_id trong yêu cầu.
Nếu mục tiêu của bạn là mỗi sự kiện Measurement Protocol đều có User-ID từ phiên trực tuyến tương ứng, thì bạn không cần đặt user_id.
Phân bổ phiên
Những sự kiện Measurement Protocol đáp ứng các yêu cầu cụ thể sẽ xuất hiện trong báo cáo với các thuộc tính phiên giống nhau (chẳng hạn như thông tin địa lý, nguồn, phương tiện và chiến dịch) như các sự kiện trực tuyến trong cùng một phiên.
Sau đây là các yêu cầu đối với mô hình phân bổ cho các phiên hoạt động:
Thêm session_id vào danh sách thông số của sự kiện.
Gửi yêu cầu chậm nhất là 24 giờ sau khi bắt đầu phiên trực tuyến.
Ví dụ: nếu phiên bắt đầu lúc 11:15 sáng thứ Hai theo múi giờ của tài sản, hãy gửi yêu cầu trước 11:15 sáng thứ Ba.
Nếu bạn ghi đè timestamp_micros, hãy đặt giá trị này thành dấu thời gian trong khoảng thời gian bắt đầu và kết thúc của phiên trực tuyến.
Xuất sự kiện sang các nền tảng quảng cáo
Google Analytics sẽ đưa các sự kiện mà bạn gửi bằng Measurement Protocol vào dữ liệu xuất sang các sản phẩm quảng cáo được liên kết, chẳng hạn như Google Ads hoặc Campaign Manager 360.
Sau đây là một số trường hợp phổ biến mà bạn nên sử dụng tính năng này:
Doanh nghiệp của bạn có các sự kiện ngoại tuyến mà bạn muốn đưa vào hoạt động phân bổ và báo cáo quảng cáo.
Bạn có thêm các sự kiện trong một hệ thống không có sẵn cho tính năng gắn thẻ hoặc SDK Firebase, nhưng bạn vẫn muốn đưa những sự kiện đó vào các sản phẩm được liên kết.
Sau đây là các yêu cầu để xuất sự kiện sang các nền tảng quảng cáo:
Gửi yêu cầu muộn nhất vào cuối ngày làm việc thứ 63 sau sự kiện trực tuyến gần đây nhất, ngay cả khi khoảng thời gian phân bổ của sự kiện chính dài hơn 63 ngày.
Ví dụ: nếu sự kiện trực tuyến mới nhất cho client_id hoặc app_instance_id xảy ra vào ngày 1 tháng 3, hãy gửi sự kiện Measurement Protocol muộn nhất vào cuối ngày làm việc ngày 3 tháng 5.
Nếu bạn ghi đè timestamp_micros, hãy đặt giá trị này thành dấu thời gian trong vòng 3 ngày làm việc gần nhất.
Gửi sự kiện hoặc thuộc tính người dùng để tạo đối tượng
Các sự kiện và thuộc tính người dùng được gửi bằng Measurement Protocol sẽ được đưa vào quá trình đánh giá điều kiện đối tượng nếu bạn tuân thủ một số yêu cầu.
Sau đây là các yêu cầu để gửi sự kiện hoặc thuộc tính người dùng cho hoạt động tạo đối tượng:
Gửi yêu cầu đến một luồng trên web muộn nhất là vào cuối ngày làm việc 30 ngày sau sự kiện trực tuyến mới nhất cho cùng một client_id.
Ví dụ: nếu sự kiện trực tuyến mới nhất cho client_id xảy ra vào ngày 1 tháng 3, hãy gửi sự kiện Measurement Protocol muộn nhất vào cuối ngày làm việc ngày 31 tháng 3.
Gửi yêu cầu đến một luồng Ứng dụng muộn nhất vào cuối ngày làm việc 42 ngày sau sự kiện trực tuyến mới nhất cho cùng một app_instance_id.
Ví dụ: nếu sự kiện trực tuyến gần đây nhất cho app_instance_id xảy ra vào ngày 1 tháng 3, hãy gửi sự kiện Measurement Protocol muộn nhất vào cuối ngày làm việc ngày 12 tháng 4.
Nếu bạn ghi đè timestamp_micros, hãy đặt giá trị này thành dấu thời gian trong vòng 3 ngày làm việc gần nhất.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-29 UTC."],[[["\u003cp\u003eThe Google Analytics Measurement Protocol allows you to send offline data, supplementing your existing online data collection.\u003c/p\u003e\n"],["\u003cp\u003eThis protocol enables you to assign User IDs to events, attribute sessions, export events for advertising, and leverage data for audience creation within Google Analytics.\u003c/p\u003e\n"],["\u003cp\u003eSpecific requirements, including session IDs and timestamps, must be met for each use case to ensure data accuracy and integration with online data.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided tables and guidelines for detailed requirements and best practices for each use case, such as session attribution and audience creation.\u003c/p\u003e\n"],["\u003cp\u003eAdhering to these guidelines ensures accurate reporting, attribution, and audience creation based on both online and offline data within your Google Analytics property.\u003c/p\u003e\n"]]],["The Google Analytics Measurement Protocol allows sending offline data to web or app streams. Key actions include: assigning User-IDs to events (requiring a `session_id`, same-day processing, and specific `timestamp_micros`), attributing sessions (requiring `session_id` and submission within 24 hours of session start), exporting events to advertising platforms (no `session_id` required, must be sent within 63 days of the last online event), and using data for audience creation (no `session_id`, web data must be sent within 30 days and app data within 42 days of the last event).\n"],null,["# Measurement protocol use cases\n\nThe Google Analytics Measurement Protocol lets you send offline data to your Web or App stream, in\naddition to the data you're already collecting with tagging or the Firebase SDK.\n\nThis guide describes common Google Analytics Measurement Protocol use cases and their requirements.\n| **Key Term:** In this guide, \"business day\" is the business day of an event or session in the [time zone of your property](//support.google.com/adsense/answer/9830725).\n\nSummary of requirements\n-----------------------\n\nThis table provides a quick reference of the requirements for each use\ncase. Keep the following best practices in mind:\n\n1. The `timestamp_micros` of events and user properties defaults to the request\n time. When sending an event or user property change that occurred in the\n past, override the timestamp as described in the [sending events](/analytics/devguides/collection/protocol/ga4/sending-events) guide and\n the [user properties](/analytics/devguides/collection/protocol/ga4/user-properties) guide.\n\n2. For accurate Realtime reports and engagement metrics, include the\n `engagement_time_msec` event parameter set to the milliseconds elapsed since\n the preceding event.\n\n| Use case | Session ID | Request time requirement | `timestamp_micros` requirement |\n|------------------------------------------------------|--------------|-----------------------------------------------------------------------------------------|---------------------------------------------------------------|\n| Assign User-ID to events | Required | \\\u003c= end of the session start's business day | \\\u003e= session start and \\\u003c= session end |\n| Session attribution | Required | \\\u003c= session start + 24 hours | \\\u003e= session start and \\\u003c= session end |\n| Export events to advertising platforms | Not required | \\\u003c= last session business day + 63 days | \\\u003e= request time minus two business days and \\\u003c= request time |\n| Send events or user properties for audience creation | Not required | Web: \\\u003c= latest online event time + 30 days App: \\\u003c= latest online event time + 42 days | \\\u003e= request time minus two business days and \\\u003c= request time |\n\nAssign User-ID to events\n------------------------\n\nUse the Measurement Protocol to provide online or offline events with a\n[User-ID](//support.google.com/analytics/answer/9213390).\n\nHere are some example use cases for adding a User-ID to an event:\n\n1. Your online measurement lacks the information needed to look up the\n User-ID for online events, but you have an event-processing pipeline that\n is able to make the association between an online session and a User-ID.\n\n In this scenario, you are using the Measurement Protocol to provide\n *online* events with a User-ID.\n2. You don't have the User-ID for events you are sending with the\n Measurement Protocol, but you want those events to be associated with a\n User-ID if the user logged in online over the course of the session.\n\n In this scenario, you are using online events to provide\n *Measurement Protocol* events with a User-ID.\n\nHere are the requirements to add a User-ID to an event:\n\n- Include the `session_id` in the event's parameter list.\n- Send the Measurement Protocol events on the *same business day* as the online session.\n- If you override `timestamp_micros`, set it to a timestamp between the start and end time of the online session.\n- If your goal is to provide User-ID for online events, set the `user_id` in the request.\n- If your goal is for each Measurement Protocol event to have the User-ID from its corresponding online session, you don't need to set `user_id`.\n\nSession attribution\n-------------------\n\nMeasurement Protocol events that meet specific requirements appear in reports\nwith the same session attributes (such as geographic information, source,\nmedium, and campaign) as online events from the same session.\n\nHere are the requirements for session attribution:\n\n- Include the `session_id` in the event's parameter list.\n- Send the request no later than 24 hours after the start of the online\n session.\n\n For example, if the session started at 11:15 AM on Monday in your property's\n time zone, send the request before 11:15 AM on Tuesday.\n- If you override `timestamp_micros`, set it to a timestamp between the\n start and end time of the online session.\n\nExport events to advertising platforms\n--------------------------------------\n\nGoogle Analytics includes the events you send using Measurement Protocol\nin exports to linked advertising products such as Google Ads or Campaign Manager\n360.\n| **Tip:** This use case doesn't require `session_id`.\n\nA few common scenarios where this is useful include:\n\n- Your business has offline events that you want included in advertising attribution and reporting.\n- You have additional events in a system that is not available to tagging or the Firebase SDK, but you still want to include those events in linked products.\n\nHere are the requirements to export events to advertising platforms:\n\n- Send the request no later than the end of the business day 63 days after\n the latest online event, even if the key event's attribution window is more\n than 63 days.\n\n For example, if the latest online event for the `client_id` or\n `app_instance_id` occurred on March 1, send the Measurement Protocol\n event no later than the end of the business day on May 3.\n- If you override `timestamp_micros`, set it to a timestamp within the last\n three business days.\n\nSend events or user properties for audience creation\n----------------------------------------------------\n\nEvents and user properties sent using Measurement Protocol are included in\nthe evaluation of [audience conditions](//support.google.com/analytics/answer/9267572) if you adhere to a few requirements.\n| **Tip:** This use case doesn't require `session_id`.\n\nHere are the requirements to send events or user properties for audience\ncreation:\n\n- Send the request to a Web stream no later than the end of the business day\n 30 days after the latest online event for the same `client_id`.\n\n For example, if the latest online event for the `client_id` occurred on\n March 1, send the Measurement Protocol event no later than the end of the\n business day on March 31.\n- Send the request to an App stream no later than the end of the business day\n 42 days after the latest online event for the same `app_instance_id`.\n\n For example, if the latest online event for the `app_instance_id` occurred\n on March 1, send the Measurement Protocol event no later than the end of\n the business day on April 12.\n- If you override `timestamp_micros`, set it to a timestamp within the last 3\n business days."]]