Google Analytics-এ পরিমাপ প্রোটোকল ইভেন্টগুলি পাঠান

এই নির্দেশিকাটি ব্যাখ্যা করে কিভাবে আপনি Google Analytics পরিমাপ প্রোটোকল ওয়েব এবং অ্যাপ স্ট্রিম ইভেন্টগুলি একটি Google Analytics সার্ভারে পাঠাতে পারেন, যাতে আপনি আপনার Google Analytics রিপোর্টে পরিমাপ প্রোটোকল ইভেন্টগুলি দেখতে পারেন।

এই নির্দেশিকাটিতে আপনি যে প্ল্যাটফর্মটি দেখতে চান তা চয়ন করুন:

অনুরোধ ফরম্যাট করুন

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-তে তৈরি হয়।

    একটি নতুন গোপনীয়তা তৈরি করতে, অ্যাডমিন > ডেটা স্ট্রীম > আপনার স্ট্রীম বেছে নিন > পরিমাপ প্রোটোকল > তৈরি করুন এ নেভিগেট করুন।

  • measurement_id : একটি স্ট্রীমের সাথে সম্পর্কিত পরিমাপ আইডি, অ্যাডমিন > ডেটা স্ট্রীম > আপনার স্ট্রীম বেছে নিন > পরিমাপ আইডির অধীনে Google Analytics UI-তে পাওয়া যায়।

    measurement_id আপনার স্ট্রিম আইডি নয়।

সম্পূর্ণ রেফারেন্সের জন্য ক্যোয়ারী প্যারামিটার দেখুন।

আপনাকে অবশ্যই অনুরোধের অংশে নিম্নলিখিতগুলি প্রদান করতে হবে:

  • client_id : একটি ক্লায়েন্টের জন্য একটি অনন্য শনাক্তকারী। এটি একটি Firebase app_instance_id থেকে আলাদা। gtag.js('get') ব্যবহার করুন।
  • user_id : ঐচ্ছিক। ব্যবহারকারীর জন্য একটি অনন্য শনাক্তকারী। শুধুমাত্র UTF-8 অক্ষর থাকতে পারে। এই শনাক্তকারী সম্পর্কে আরও তথ্যের জন্য ক্রস-প্ল্যাটফর্ম বিশ্লেষণের জন্য ব্যবহারকারী-আইডি দেখুন।

  • consent : ঐচ্ছিক। সম্মতি সেটিংস কীভাবে সেট করবেন তা জানুন।

  • timestamp_micros : ঐচ্ছিক। ইউনিক্স যুগের সময়, মাইক্রোসেকেন্ডে, অনুরোধে ইভেন্ট এবং ব্যবহারকারীর বৈশিষ্ট্যের জন্য। নির্দিষ্ট করা না থাকলে, অনুরোধের সময় ডিফল্ট

  • events : ইভেন্ট আইটেম একটি অ্যারে. আপনি একটি অনুরোধে একাধিক ইভেন্ট অন্তর্ভুক্ত করতে পারেন।

    রিয়েলটাইমের মতো প্রতিবেদনে ব্যবহারকারীর কার্যকলাপ প্রদর্শনের জন্য, একটি event জন্য params অংশ হিসেবে engagement_time_msec এবং session_id অবশ্যই সরবরাহ করতে হবে। engagement_time_msec প্যারামিটারটি মিলিসেকেন্ডে ইভেন্টের ব্যস্ততার সময়কে প্রতিফলিত করবে।

    এখানে একটি উদাহরণ:

```json { "client_id": "123456.7654321", "events": [ { "name": "campaign_details", "params": { "campaign_id": "google_1234", "campaign": "Summer_fun", "source": "google", "medium": "cpc", "term": "summer+travel", "content": "logolink", "session_id": "123", "engagement_time_msec": "100" } } ] } ``` While `session_start` is a [reserved event name](/analytics/devguides/collection/protocol/ga4/reference#reserved_names), creating a new `session_id` creates a new session without the need to send `session_start`. Understand how [sessions are counted](//support.google.com/analytics/answer/9191807). ## Try it Here's an example you can use to send a [`tutorial_begin`] event to your Google Analytics server: ```javascript const measurement_id = `G-XXXXXXXXXX`; const api_secret = `<secret_value>`; fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`, { method: "POST", body: JSON.stringify({ client_id: 'XXXXXXXXXX.YYYYYYYYYY', events: [{ name: 'tutorial_begin', params: {}, }] }) }); ``` ## Override timestamp The Measurement Protocol uses the *first* timestamp it finds in the following list for each event in the request: 1. The `timestamp_micros` of the event. 1. The `timestamp_micros` of the request. 1. The time that the Measurement Protocol receives the request. The following example sends a request-level timestamp that applies to all of the events in the request. As a result, the Measurement Protocol assigns both the `tutorial_begin` and `join_group` events a timestamp of `requestUnixEpochTimeInMicros`. ```javascript { "timestamp_micros": requestUnixEpochTimeInMicros, "events": [ { "name": "tutorial_begin" }, { "name": "join_group", "params": { "group_id": "G_12345", } } ] } ``` The following example sends both a request-level timestamp and an event-level timestamp. As a result, the Measurement Protocol assigns the `tutorial_begin` event a timestamp of `tutorialBeginUnixEpochTimeInMicros`, and the `join_group` event a timestamp of `requestUnixEpochTimeInMicros`. ```javascript { "timestamp_micros": requestUnixEpochTimeInMicros, "events": [ { "name": "tutorial_begin", "timestamp_micros": tutorialBeginUnixEpochTimeInMicros }, { "name": "join_group", "params": { "group_id": "G_12345", } } ] } ``` ## Limitations The following limitations apply to sending Measurement Protocol events to Google Analytics: Note: For information on the limitations of 360 features, see [Google Analytics 360](//support.google.com/analytics/answer/11202874). * Requests can have a maximum of 25 events. * Events can have a maximum of 25 parameters. * Events can have a maximum of 25 user properties. * User property names must be 24 characters or fewer. * User property values must be 36 characters or fewer. * Event names must be 40 characters or fewer, can only contain alpha-numeric characters and underscores, and must start with an alphabetic character. * Parameter names including item parameters must be 40 characters or fewer, can only contain alpha-numeric characters and underscores, and must start with an alphabetic character. * 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. * Item parameters can have a maximum of 10 custom parameters. * The post body must be smaller than 130kB. * App Measurement Protocol events sent to Google Analytics 4 don't populate Search audiences in Google Ads for app users. For additional requirements of each use case, see [common use cases].