Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Protokół pomiarowy Google Analytics umożliwia przesyłanie danych offline do strumienia danych z witryny lub aplikacji, oprócz danych, które już zbierasz za pomocą tagowania lub pakietu SDK Firebase.
W tym przewodniku opisujemy typowe przypadki użycia Measurement Protocol w Google Analytics i ich wymagania.
Podsumowanie wymagań
W tabeli poniżej znajdziesz krótki przegląd wymagań poszczególnych przypadków użycia. Pamiętaj o tych sprawdzonych metodach:
Parametr timestamp_micros w zdarzeniach i właściwościach użytkownika podaje domyślnie czas żądania. Przy wysyłaniu zmiany, która miała miejsce w przeszłości, a dotyczy zdarzenia lub właściwości użytkownika, zastąp sygnaturę czasową w sposób podany w przewodniku po wysyłaniu zdarzeń i po właściwościach użytkownika.
Aby otrzymywać dokładne raporty Czas rzeczywisty i wskaźniki zaangażowania, przekazuj parametr zdarzenia
engagement_time_msec podający liczbę milisekund, która upłynęła od poprzedniego zdarzenia.
Przypadek użycia
Identyfikator sesji
Wymaganie dotyczące czasu żądania
Wymaganie timestamp_micros
Przypisywanie identyfikatorów User-ID do zdarzeń
Wymagane
<= koniec sesji, dzień roboczy początku sesji
>= początek sesji oraz <= koniec sesji
Atrybucja sesji
Wymagane
<= początek sesji + 24 godziny
>= początek sesji oraz <= koniec sesji
Eksportowanie zdarzeń na platformy reklamowe
Niewymagane
<= dzień roboczy ostatniej sesji + 63 dni
>= czas żądania minus 2 dni robocze i <= czas żądania
Wysyłanie zdarzeń lub właściwości użytkownika na potrzeby tworzenia list odbiorców
Niewymagane
Internet: <= czas najnowszego zdarzenia online + 30 dni
Aplikacja: <= czas najnowszego zdarzenia online + 42 dni
>= czas żądania minus 2 dni robocze i <= czas żądania
Przypisywanie identyfikatorów User-ID do zdarzeń
Używaj platformy Measurement Protocol, aby przekazywać zdarzenia online lub offline z identyfikatorem User-ID.
Oto kilka przykładowych przypadków użycia dodawania identyfikatora User-ID do zdarzenia:
Twoje pomiary online nie zawierają informacji potrzebnych do wyszukania identyfikatora użytkownika w przypadku zdarzeń online, ale masz potok przetwarzania zdarzeń, który może powiązać sesję online z identyfikatorem użytkownika.
W tym scenariuszu używasz platformy Measurement Protocol do przekazywania zdarzeń online z identyfikatorem użytkownika.
Nie masz identyfikatora User-ID w przypadku zdarzeń wysyłanych za pomocą protokołu pomiarowego, ale chcesz, aby te zdarzenia były powiązane z identyfikatorem User-ID, jeśli użytkownik zaloguje się online w trakcie sesji.
W tym scenariuszu używasz zdarzeń online, aby przekazywać zdarzenia Measurement Protocol z identyfikatorem użytkownika.
Oto wymagania dotyczące dodawania identyfikatora User-ID do zdarzenia:
Dodaj session_id do listy parametrów zdarzenia.
Wysyłaj zdarzenia Measurement Protocol w tym samym dniu roboczym co sesja online.
Jeśli zastąpisz parametr timestamp_micros, ustaw go na sygnaturę czasową między czasem rozpoczęcia a zakończenia sesji online.
Jeśli chcesz podawać identyfikator User-ID w przypadku zdarzeń online, ustaw w żądaniu parametr user_id.
Jeśli chcesz, aby każde zdarzenie protokołu Measurement Protocol miało identyfikator User-ID z odpowiedniej sesji online, nie musisz ustawiać parametru user_id.
Atrybucja sesji
Zdarzenia platformy Measurement Protocol, które spełniają określone wymagania, pojawiają się w raportach z tymi samymi atrybutami sesji (np. informacje geograficzne, źródło, medium i kampania) co zdarzenia online z tej samej sesji.
Oto wymagania dotyczące atrybucji sesji:
Dodaj session_id do listy parametrów zdarzenia.
Wyślij prośbę nie później niż 24 godziny po rozpoczęciu sesji online.
Jeśli np. sesja rozpoczęła się o 11:15 w poniedziałek w strefie czasowej usługi, wyślij żądanie przed 11:15 we wtorek.
Jeśli zastąpisz parametr timestamp_micros, ustaw go na sygnaturę czasową między czasem rozpoczęcia a zakończenia sesji online.
Eksportowanie zdarzeń na platformy reklamowe
Google Analytics uwzględnia zdarzenia wysyłane za pomocą Measurement Protocol w eksportach do połączonych usług reklamowych, takich jak Google Ads czy Campaign Manager 360.
Oto kilka typowych scenariuszy, w których ta funkcja może być przydatna:
Twoja firma organizuje wydarzenia offline, które chcesz uwzględniać w atrybucji i raportowaniu reklam.
W systemie, który nie jest dostępny dla tagowania ani pakietu SDK Firebase, masz dodatkowe zdarzenia, ale nadal chcesz uwzględniać je w połączonych usługach.
Oto wymagania dotyczące eksportowania zdarzeń na platformy reklamowe:
Wyślij prośbę nie później niż do końca dnia roboczego 63 dni po ostatnim zdarzeniu online, nawet jeśli okres atrybucji kluczowego zdarzenia jest dłuższy niż 63 dni.
Jeśli na przykład ostatnie zdarzenie online dla client_id lub app_instance_id miało miejsce 1 marca, wyślij zdarzenie Measurement Protocol najpóźniej do końca dnia roboczego 3 maja.
Jeśli zastępujesz wartość timestamp_micros, ustaw ją na sygnaturę czasową z ostatnich 3 dni roboczych.
Wysyłanie zdarzeń lub właściwości użytkownika na potrzeby tworzenia list odbiorców
Zdarzenia i właściwości użytkownika wysyłane za pomocą Measurement Protocol są uwzględniane w ocenie warunków odbiorców, jeśli spełniasz kilka wymagań.
Oto wymagania dotyczące wysyłania zdarzeń lub właściwości użytkownika na potrzeby tworzenia list odbiorców:
Prześlij żądanie do strumienia danych z internetu nie później niż do końca dnia roboczego 30 dni po ostatnim zdarzeniu online dotyczącym tego samego client_id.
Jeśli np. ostatnie zdarzenie online dotyczące client_id miało miejsce 1 marca, wyślij zdarzenie Measurement Protocol najpóźniej do końca dnia roboczego 31 marca.
Prześlij żądanie do strumienia danych z aplikacji nie później niż do końca dnia roboczego 42 dni po najnowszym zdarzeniu online dotyczącym tego samego app_instance_id.
Jeśli np. ostatnie zdarzenie online dla app_instance_id miało miejsce 1 marca, wyślij zdarzenie Measurement Protocol najpóźniej do końca dnia roboczego 12 kwietnia.
Jeśli zastępujesz wartość parametru timestamp_micros, ustaw ją na sygnaturę czasową z ostatnich 3 dni roboczych.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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."]]