এই নির্দেশিকাটিতে আপনি যে প্ল্যাটফর্মটি দেখতে চান তা চয়ন করুন:
অনুরোধ ফরম্যাট করুন
Google Analytics পরিমাপ প্রোটোকল শুধুমাত্র HTTP POST অনুরোধ সমর্থন করে।
একটি ইভেন্ট পাঠাতে, নিম্নলিখিত বিন্যাস ব্যবহার করুন:
POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json
PAYLOAD_DATA
অনুরোধ URL-এ আপনাকে অবশ্যই নিম্নলিখিতগুলি প্রদান করতে হবে:
api_secret : এপিআই সিক্রেট গুগল অ্যানালিটিক্স UI-তে তৈরি হয়।
একটি নতুন গোপনীয়তা তৈরি করতে, অ্যাডমিন > ডেটা সংগ্রহ এবং পরিবর্তন > ডেটা স্ট্রীম > আপনার স্ট্রিম চয়ন করুন > পরিমাপ প্রোটোকল API গোপনীয়তা > তৈরি করুন এ নেভিগেট করুন।
measurement_id : একটি স্ট্রীমের সাথে সম্পর্কিত পরিমাপ আইডি, অ্যাডমিন > ডেটা স্ট্রীম > আপনার স্ট্রীম বেছে নিন > পরিমাপ আইডির অধীনে Google Analytics UI-তে পাওয়া যায়।
measurement_id আপনার স্ট্রিম আইডি নয়।
আপনাকে অবশ্যই পরিমাপ প্রোটোকলের জন্য JSON POST বডি ফরম্যাটে একটি অনুরোধের বডি প্রদান করতে হবে। এখানে একটি উদাহরণ:
এখানে একটি উদাহরণ রয়েছে যা আপনি একবারে একাধিক ইভেন্ট পাঠাতে ব্যবহার করতে পারেন৷ এই উদাহরণটি আপনার Google Analytics সার্ভারে একটি tutorial_begin ইভেন্ট এবং একটি join_group ইভেন্ট পাঠায়, user_location ক্ষেত্র ব্যবহার করে ভৌগলিক তথ্য অন্তর্ভুক্ত করে এবং device ক্ষেত্র ব্যবহার করে ডিভাইসের তথ্য অন্তর্ভুক্ত করে।
পরিমাপ প্রোটোকল অনুরোধে প্রতিটি ইভেন্টের জন্য নিম্নলিখিত তালিকায় পাওয়া প্রথম টাইমস্ট্যাম্প ব্যবহার করে:
ইভেন্টের timestamp_micros ।
অনুরোধের timestamp_micros ।
যে সময় পরিমাপ প্রোটোকল অনুরোধ গ্রহণ করে।
নিম্নলিখিত উদাহরণটি একটি অনুরোধ-স্তরের টাইমস্ট্যাম্প পাঠায় যা অনুরোধের সমস্ত ইভেন্টে প্রযোজ্য। ফলস্বরূপ, পরিমাপ প্রোটোকল tutorial_begin এবং join_group ইভেন্ট উভয়কেই requestUnixEpochTimeInMicros এর একটি টাইমস্ট্যাম্প বরাদ্দ করে।
নিম্নলিখিত উদাহরণটি অনুরোধ-স্তরের টাইমস্ট্যাম্প এবং একটি ইভেন্ট-স্তরের টাইমস্ট্যাম্প উভয়ই পাঠায়। ফলস্বরূপ, পরিমাপ প্রোটোকল tutorial_begin ইভেন্টটিকে tutorialBeginUnixEpochTimeInMicros এর একটি টাইমস্ট্যাম্প এবং join_group ইভেন্টটিকে requestUnixEpochTimeInMicros এর একটি টাইমস্ট্যাম্প নির্ধারণ করে।
Google Analytics-এ পরিমাপ প্রোটোকল ইভেন্ট পাঠানোর ক্ষেত্রে নিম্নলিখিত সীমাবদ্ধতাগুলি প্রযোজ্য:
অনুরোধে সর্বাধিক 25টি ইভেন্ট থাকতে পারে।
ইভেন্টে সর্বাধিক 25টি প্যারামিটার থাকতে পারে।
ইভেন্টে সর্বাধিক 25টি ব্যবহারকারীর বৈশিষ্ট্য থাকতে পারে।
ব্যবহারকারীর সম্পত্তির নাম অবশ্যই 24 অক্ষর বা তার কম হতে হবে।
ব্যবহারকারীর সম্পত্তির মান অবশ্যই 36 অক্ষর বা তার কম হতে হবে।
ইভেন্টের নাম অবশ্যই 40 অক্ষর বা তার কম হতে হবে, শুধুমাত্র বর্ণসংখ্যার অক্ষর এবং আন্ডারস্কোর থাকতে পারে এবং একটি বর্ণানুক্রমিক অক্ষর দিয়ে শুরু করতে হবে।
আইটেম প্যারামিটার সহ প্যারামিটারের নামগুলি অবশ্যই 40 অক্ষর বা তার কম হতে হবে, শুধুমাত্র বর্ণসংখ্যার অক্ষর এবং আন্ডারস্কোর থাকতে পারে এবং একটি বর্ণানুক্রমিক অক্ষর দিয়ে শুরু করতে হবে।
আইটেম প্যারামিটার মান সহ প্যারামিটার মান একটি আদর্শ Google Analytics প্রপার্টির জন্য 100 অক্ষর বা তার কম এবং একটি Google Analytics 360 প্রপার্টির জন্য 500 বা তার কম অক্ষর হতে হবে।
আইটেম প্যারামিটারে সর্বাধিক 10টি কাস্টম প্যারামিটার থাকতে পারে।
পোস্ট বডি অবশ্যই 130kB এর থেকে ছোট হতে হবে।
Google Analytics-এ পাঠানো অ্যাপ মেজারমেন্ট প্রোটোকল ইভেন্ট অ্যাপ ব্যবহারকারীদের জন্য Google বিজ্ঞাপনে সার্চ অডিয়েন্স তৈরি করে না।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-09-04 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis guide explains how to send web and app stream events to a Google Analytics server using the Measurement Protocol.\u003c/p\u003e\n"],["\u003cp\u003eYou must format the request as an HTTP POST request and include your API Secret and Measurement ID in the URL.\u003c/p\u003e\n"],["\u003cp\u003eThe request body should contain client ID, optional user ID and consent settings, timestamp, and an array of events.\u003c/p\u003e\n"],["\u003cp\u003eEvents can include parameters like \u003ccode\u003eengagement_time_msec\u003c/code\u003e and \u003ccode\u003esession_id\u003c/code\u003e to display user activity in Realtime reports.\u003c/p\u003e\n"],["\u003cp\u003eThe Measurement Protocol has limitations on the number of events, parameters, and user properties allowed in a single request.\u003c/p\u003e\n"]]],["To send events to Google Analytics, use HTTP `POST` requests to `www.google-analytics.com/mp/collect`. Include `api_secret` and `measurement_id` in the URL. The request body should include `client_id`, and optionally `user_id`, `consent`, and `timestamp_micros`. Send events as an array within the `events` key. For real-time reporting, include `engagement_time_msec` and `session_id` in the event parameters. Timestamps can be set per event or at the request level. There are limitations on request size, event, and parameter counts.\n"],null,["This guide explains how you can send\n[Google Analytics Measurement Protocol](/analytics/devguides/collection/protocol/ga4) web and app stream\n[events](/analytics/devguides/collection/protocol/ga4/reference/events) to a\nGoogle Analytics server, so that you can view Measurement Protocol events in your\n[Google Analytics reports](/analytics/devguides/reporting/data/v1/basics).\n\nChoose the platform you want to see in this guide: \nFirebase gtag.js\n\nFormat the request\n\nThe Google Analytics Measurement Protocol only supports HTTP `POST` requests.\n\nTo send an event, use the following format: \n\n POST /mp/collect HTTP/1.1\n HOST: www.google-analytics.com\n Content-Type: application/json\n\n \u003cvar translate=\"no\"\u003ePAYLOAD_DATA\u003c/var\u003e\n\n| **Tip:** If you want your data to be collected in the EU, change the `HOST` in the example to `region1.google-analytics.com`.\n\nYou must provide the following in the request URL:\n\n- `api_secret`: The **API SECRET** generated in the Google Analytics UI.\n\n To create a new secret, navigate to\n **Admin** \\\u003e **Data collection and modification** \\\u003e **Data streams** \\\u003e\n **choose your stream** \\\u003e **Measurement Protocol API secrets** \\\u003e **Create**.\n\n\u003cbr /\u003e\n\n- `measurement_id`: The measurement ID associated with a stream, found in the\n Google Analytics UI under **Admin** \\\u003e **Data Streams** \\\u003e **choose your\n stream** \\\u003e **Measurement ID**.\n\n The `measurement_id` isn't your **Stream ID**.\n\nYou must provide a request body in the [JSON POST body](/analytics/devguides/collection/protocol/ga4/reference#payload_post_body) format for\nthe Measurement Protocol. Here's an example:\n\n\u003cbr /\u003e\n\n {\n \"client_id\": \"\u003cvar translate=\"no\"\u003eCLIENT_ID\u003c/var\u003e\",\n \"events\": [\n {\n \"name\": \"login\",\n \"params\": {\n \"method\": \"Google\",\n \"session_id\": \"\u003cvar translate=\"no\"\u003eSESSION_ID\u003c/var\u003e\",\n \"engagement_time_msec\": 100\n }\n }\n ]\n }\n\nWhile `session_start` is a [reserved event\nname](/analytics/devguides/collection/protocol/ga4/reference#reserved_names),\ncreating a new `session_id` creates a new session without the need to send\n`session_start`. Understand how [sessions are\ncounted](//support.google.com/analytics/answer/9191807).\n\nTry it\n\nHere's an example you can use to send multiple events at once. This example\nsends a [`tutorial_begin`](/analytics/devguides/collection/protocol/ga4/reference/events?tech=aw_measurement_protocol#tutorial_begin) event and a\n[`join_group`](/analytics/devguides/collection/protocol/ga4/reference/events?tech=aw_measurement_protocol#join_group) event to your Google Analytics server, includes [geographic\ninformation](/analytics/devguides/collection/protocol/ga4/reference#payload_geo_info) using the `user_location` field, and includes [device information](/analytics/devguides/collection/protocol/ga4/reference#payload_device_info)\nusing the `device` field.\n\n\u003cbr /\u003e\n\n const measurementId = \"\u003cvar translate=\"no\"\u003eMEASUREMENT_ID\u003c/var\u003e\";\n const apiSecret = \"\u003cvar translate=\"no\"\u003eAPI_SECRET\u003c/var\u003e\";\n\n fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`, {\n method: \"POST\",\n body: JSON.stringify({\n client_id: \"\u003cvar translate=\"no\"\u003eCLIENT_ID\u003c/var\u003e\",\n events: [\n {\n name: \"tutorial_begin\",\n params: {\n \"session_id\": \"\u003cvar translate=\"no\"\u003eSESSION_ID\u003c/var\u003e\",\n \"engagement_time_msec\": 100\n }\n },\n {\n name: \"join_group\",\n params: {\n \"group_id\": \"G_12345\",\n \"session_id\": \"\u003cvar translate=\"no\"\u003eSESSION_ID\u003c/var\u003e\",\n \"engagement_time_msec\": 150\n }\n }\n ],\n user_location: {\n city: \"Mountain View\",\n region_id: \"US-CA\",\n country_id: \"US\",\n subcontinent_id: \"021\",\n continent_id: \"019\"\n },\n device: {\n category: \"mobile\",\n language: \"en\",\n screen_resolution: \"1280x2856\",\n operating_system: \"Android\",\n operating_system_version: \"14\",\n model: \"Pixel 9 Pro\",\n brand: \"Google\",\n browser: \"Chrome\",\n browser_version: \"136.0.7103.60\"\n }\n })\n });\n\nOverride timestamp\n\nThe Measurement Protocol uses the *first* timestamp it finds in the following list\nfor each event in the request:\n\n1. The `timestamp_micros` of the event.\n2. The `timestamp_micros` of the request.\n3. The time that the Measurement Protocol receives the request.\n\nThe following example sends a request-level timestamp that applies to all of the\nevents in the request. As a result, the Measurement Protocol assigns both the\n`tutorial_begin` and `join_group` events a timestamp of\n`requestUnixEpochTimeInMicros`. \n\n {\n \"timestamp_micros\": requestUnixEpochTimeInMicros,\n \"events\": [\n {\n \"name\": \"tutorial_begin\"\n },\n {\n \"name\": \"join_group\",\n \"params\": {\n \"group_id\": \"G_12345\",\n }\n }\n ]\n }\n\nThe following example sends both a request-level timestamp and an event-level\ntimestamp. As a result, the Measurement Protocol assigns the `tutorial_begin`\nevent a timestamp of `tutorialBeginUnixEpochTimeInMicros`, and the `join_group`\nevent a timestamp of `requestUnixEpochTimeInMicros`. \n\n {\n \"timestamp_micros\": requestUnixEpochTimeInMicros,\n \"events\": [\n {\n \"name\": \"tutorial_begin\",\n \"timestamp_micros\": tutorialBeginUnixEpochTimeInMicros\n },\n {\n \"name\": \"join_group\",\n \"params\": {\n \"group_id\": \"G_12345\",\n }\n }\n ]\n }\n\nLimitations\n\nThe following limitations apply to sending Measurement Protocol events to Google\nAnalytics:\n| **Note:** For information on the limitations of 360 features, see [Google Analytics\n| 360](//support.google.com/analytics/answer/11202874).\n\n- Requests can have a maximum of 25 events.\n- Events can have a maximum of 25 parameters.\n- Events can have a maximum of 25 user properties.\n- User property names must be 24 characters or fewer.\n- User property values must be 36 characters or fewer.\n- Event names must be 40 characters or fewer, can only contain alphanumeric characters and underscores, and must start with an alphabetic character.\n- Parameter names including item parameters must be 40 characters or fewer, can only contain alphanumeric characters and underscores, and must start with an alphabetic character.\n- Parameter values including item parameter values must be 100 characters or fewer for a standard Google Analytics property, and 500 characters or fewer for a Google Analytics 360 property.\n- Item parameters can have a maximum of 10 custom parameters.\n- The post body must be smaller than 130kB.\n- App Measurement Protocol events sent to Google Analytics don't populate Search audiences in Google Ads for app users.\n\nFor additional requirements of each use case, see [common use cases](/analytics/devguides/collection/protocol/ga4/use-cases)."]]