با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پروتکل اندازهگیری Google Analytics به شما امکان میدهد تا دادههای آفلاین را به جریان وب یا برنامه خود ارسال کنید، علاوه بر دادههایی که قبلاً با برچسبگذاری یا Firebase SDK جمعآوری میکنید.
این راهنما موارد رایج استفاده از پروتکل اندازهگیری Google Analytics و الزامات آنها را شرح میدهد.
خلاصه الزامات
این جدول یک مرجع سریع از الزامات برای هر مورد استفاده ارائه می دهد. بهترین روش های زیر را در ذهن داشته باشید:
timestamp_micros رویدادها و خصوصیات کاربر به طور پیشفرض روی زمان درخواست است. هنگام ارسال یک رویداد یا تغییر ویژگی کاربر که در گذشته رخ داده است، همانطور که در راهنمای رویدادهای ارسال و راهنمای ویژگی های کاربر توضیح داده شده است، مهر زمانی را لغو کنید.
برای گزارشهای بیدرنگ و معیارهای تعامل، پارامتر رویداد engagement_time_msec را روی میلیثانیههای سپری شده از رویداد قبلی تنظیم کنید.
مورد استفاده
شناسه جلسه
درخواست زمان مورد نیاز
نیاز timestamp_micros
User-ID را به رویدادها اختصاص دهید
مورد نیاز
<= پایان جلسه در روز کاری شروع
>= شروع جلسه و <= پایان جلسه
انتساب جلسه
مورد نیاز
<= شروع جلسه + 24 ساعت
>= شروع جلسه و <= پایان جلسه
صادرات رویدادها به سیستم عامل های تبلیغاتی
لازم نیست
<= آخرین جلسه روز کاری + 63 روز
>= زمان درخواست منهای دو روز کاری و <= زمان درخواست
رویدادها یا ویژگی های کاربر را برای ایجاد مخاطب ارسال کنید
لازم نیست
وب: <= آخرین زمان رویداد آنلاین + 30 روز برنامه: <= آخرین زمان رویداد آنلاین + 42 روز
>= زمان درخواست منهای دو روز کاری و <= زمان درخواست
User-ID را به رویدادها اختصاص دهید
از پروتکل اندازه گیری برای ارائه رویدادهای آنلاین یا آفلاین با شناسه کاربر استفاده کنید.
در اینجا چند نمونه از موارد استفاده برای افزودن User-ID به یک رویداد آورده شده است:
اندازهگیری آنلاین شما فاقد اطلاعات لازم برای جستجوی User-ID برای رویدادهای آنلاین است، اما شما یک خط لوله پردازش رویداد دارید که میتواند بین یک جلسه آنلاین و یک User-ID ارتباط برقرار کند.
در این سناریو، شما از پروتکل اندازه گیری برای ارائه رویدادهای آنلاین با User-ID استفاده می کنید.
شما شناسه کاربر رویدادهایی را که با پروتکل اندازهگیری ارسال میکنید ندارید، اما میخواهید در صورتی که کاربر در طول جلسه به صورت آنلاین وارد شده باشد، این رویدادها با شناسه کاربری مرتبط شوند.
در این سناریو، شما از رویدادهای آنلاین برای ارائه رویدادهای پروتکل اندازه گیری با User-ID استفاده می کنید.
در اینجا شرایط لازم برای افزودن User-ID به یک رویداد وجود دارد:
session_id در لیست پارامترهای رویداد قرار دهید.
رویدادهای پروتکل اندازه گیری را در همان روز کاری جلسه آنلاین ارسال کنید.
اگر timestamp_micros را لغو کردید، آن را روی مهر زمانی بین زمان شروع و پایان جلسه آنلاین تنظیم کنید.
اگر هدف شما ارائه User-ID برای رویدادهای آنلاین است، user_id در درخواست تنظیم کنید.
اگر هدف شما این است که هر رویداد پروتکل اندازهگیری، User-ID را از جلسه آنلاین مربوطه خود داشته باشد، نیازی به تنظیم user_id ندارید.
انتساب جلسه
رویدادهای پروتکل اندازهگیری که الزامات خاصی را برآورده میکنند در گزارشهایی با ویژگیهای جلسه مشابه (مانند اطلاعات جغرافیایی، منبع، رسانه و کمپین) مانند رویدادهای آنلاین از همان جلسه ظاهر میشوند.
در اینجا شرایط لازم برای انتساب جلسه وجود دارد:
session_id در لیست پارامترهای رویداد قرار دهید.
درخواست را حداکثر تا 24 ساعت پس از شروع جلسه آنلاین ارسال کنید.
به عنوان مثال، اگر جلسه در ساعت 11:15 صبح روز دوشنبه در منطقه زمانی ملک شما شروع شده است، درخواست را قبل از ساعت 11:15 صبح روز سه شنبه ارسال کنید.
اگر timestamp_micros را لغو کردید، آن را روی مهر زمانی بین زمان شروع و پایان جلسه آنلاین تنظیم کنید.
صادرات رویدادها به سیستم عامل های تبلیغاتی
Google Analytics شامل رویدادهایی است که با استفاده از پروتکل اندازه گیری در صادرات به محصولات تبلیغاتی مرتبط مانند Google Ads یا Campaign Manager 360 ارسال می کنید.
چند سناریو رایج که در آنها مفید است عبارتند از:
کسب و کار شما رویدادهای آفلاینی دارد که میخواهید در اسناد و گزارشهای تبلیغاتی لحاظ شوند.
شما رویدادهای دیگری در سیستمی دارید که برای برچسبگذاری یا Firebase SDK در دسترس نیست، اما همچنان میخواهید آن رویدادها را در محصولات مرتبط قرار دهید.
در اینجا شرایط لازم برای صادرات رویدادها به سیستم عامل های تبلیغاتی وجود دارد:
درخواست را حداکثر تا پایان روز کاری 63 روز پس از آخرین رویداد آنلاین ارسال کنید، حتی اگر پنجره اسناد رویداد کلیدی بیش از 63 روز باشد.
برای مثال، اگر آخرین رویداد آنلاین برای client_id یا app_instance_id در 1 مارس رخ داده است، رویداد Protocol اندازهگیری را حداکثر تا پایان روز کاری در 3 مه ارسال کنید.
اگر timestamp_micros لغو کردید، آن را روی مهر زمانی در سه روز کاری گذشته تنظیم کنید.
رویدادها یا ویژگی های کاربر را برای ایجاد مخاطب ارسال کنید
رویدادها و ویژگیهای کاربر که با استفاده از پروتکل اندازهگیری ارسال میشوند، در صورت رعایت چند الزام، در ارزیابی شرایط مخاطب لحاظ میشوند.
در اینجا شرایط لازم برای ارسال رویدادها یا ویژگی های کاربر برای ایجاد مخاطب وجود دارد:
درخواست را حداکثر تا پایان روز کاری 30 روز پس از آخرین رویداد آنلاین برای همان client_id به یک جریان وب ارسال کنید.
به عنوان مثال، اگر آخرین رویداد آنلاین برای client_id در 1 مارس رخ داده است، رویداد Protocol اندازه گیری را حداکثر تا پایان روز کاری در 31 مارس ارسال کنید.
درخواست را حداکثر تا پایان روز کاری 42 روز پس از آخرین رویداد آنلاین برای همان app_instance_id به یک جریان برنامه ارسال کنید.
برای مثال، اگر آخرین رویداد آنلاین برای app_instance_id در 1 مارس رخ داده است، رویداد پروتکل اندازهگیری را حداکثر تا پایان روز کاری در 12 آوریل ارسال کنید.
اگر timestamp_micros لغو کردید، آن را روی مهر زمانی در 3 روز کاری گذشته تنظیم کنید.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]