با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این راهنما به شما نشان می دهد که چگونه رویدادها را در برنامه خود ثبت کنید.
رویدادها بینشی در مورد آنچه در برنامه شما اتفاق میافتد، مانند اقدامات کاربر، رویدادهای سیستم یا خطاها ارائه میدهند.
Analytics به طور خودکار برخی از رویدادها را برای شما ثبت می کند. برای دریافت آنها نیازی به افزودن کد ندارید. اگر برنامه شما نیاز به جمع آوری داده های اضافی دارد، می توانید تا 500 نوع مختلف رویداد Analytics را در برنامه خود ثبت کنید. هیچ محدودیتی در حجم کل رویدادهایی که برنامه شما ثبت می کند وجود ندارد. توجه داشته باشید که نام رویدادها به حروف بزرگ و کوچک حساس هستند و ثبت دو رویداد که نام آنها فقط در حروف بزرگ متفاوت است منجر به دو رویداد مجزا می شود.
قبل از شروع
مطمئن شوید که پروژه خود را راهاندازی کردهاید و میتوانید همانطور که در Get Started with Analytics توضیح داده شده است به Analytics دسترسی داشته باشید.
ثبت رویدادها
پس از پیکربندی نمونه firebase.analytics() ، می توانید ثبت رویدادها را با متد logEvent() شروع کنید. اگر قبلاً با Google Analytics آشنا هستید، این روش معادل استفاده از دستور event در gtag.js است.
برای کمک به شروع، Analytics SDK تعدادی رویداد توصیه شده را تعریف میکند که در بین انواع مختلف برنامهها، از جمله برنامههای خردهفروشی و تجارت الکترونیک، سفر، و بازی مشترک هستند. برای اطلاعات بیشتر درباره این رویدادها و زمان استفاده از آنها، به رویدادهای توصیه شده مراجعه کنید.
توجه: برای دریافت حداکثر جزئیات در گزارشها، رویدادهای توصیهشدهای را که برای برنامه شما و پارامترهای تعیینشده آن معنا دارند، ثبت کنید. این همچنین تضمین می کند که از آخرین ویژگی های گوگل آنالیتیکس به محض در دسترس قرار گرفتن آنها بهره مند شوید.
میتوانید جزئیات پیادهسازی چندین رویداد و پارامترهای آنها را در مرجع رویداد gtag.js پیدا کنید.
مثال زیر نحوه ثبت رویداد select_content را نشان می دهد:
علاوه بر پارامترهای تعیین شده، می توانید پارامترهای زیر را به هر رویداد اضافه کنید:
پارامترهای سفارشی: پارامترهای سفارشی را می توان به عنوان ابعاد یا معیارها در گزارش های Analytics استفاده کرد. میتوانید از ابعاد سفارشی برای دادههای پارامتر رویداد غیر عددی و معیارهای سفارشی برای هر داده پارامتری که بهتر به صورت عددی نمایش داده میشود، استفاده کنید. هنگامی که یک پارامتر سفارشی را با استفاده از SDK ثبت کردید، بعد یا متریک را ثبت کنید تا مطمئن شوید که آن پارامترهای سفارشی در گزارشهای Analytics ظاهر میشوند. این کار را از طریق: Analytics > Events > Manage Custom Definitions > Create Custom Dimensions انجام دهید
پارامترهای سفارشی را می توان در تعاریف مخاطب استفاده کرد که ممکن است برای هر گزارش اعمال شود. اگر برنامه شما به پروژه BigQuery مرتبط باشد، پارامترهای سفارشی نیز در دادههای صادر شده به BigQuery گنجانده میشوند. جستجوهای نمونه و موارد دیگر را در Google Analytics 4 BigQuery Export بیابید.
پارامتر value : value یک پارامتر هدف عمومی است که برای جمع آوری یک معیار کلیدی که مربوط به یک رویداد است مفید است. به عنوان مثال می توان به درآمد، مسافت، زمان و امتیاز اشاره کرد.
اگر برنامه شما نیازهای خاصی دارد که توسط یک نوع رویداد توصیه شده پوشش داده نشده است، می توانید رویدادهای سفارشی خود را ثبت کنید. برای مثال، اگر در حال توسعه یک بازی هستید و میخواهید زمانی که یک بازیکن هدف خاصی را تکمیل میکند، ردیابی کنید، میتوانید رویدادی مشابه مثال زیر را ثبت کنید:
در داشبوردهای کنسول Firebase میتوانید آمار انبوه رویدادهای خود را مشاهده کنید. این داشبوردها به صورت دوره ای در طول روز به روز می شوند. برای آزمایش فوری، از خروجی logcat همانطور که در بخش قبل توضیح داده شد استفاده کنید.
میتوانید از داشبورد رویدادها در کنسول Firebase به این دادهها دسترسی پیدا کنید. این داشبورد گزارشهای رویدادی را نشان میدهد که بهطور خودکار برای هر نوع متمایزی از رویداد ثبتشده توسط برنامه شما ایجاد میشوند.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\niOS+ Android Web Flutter \n\n\u003cbr /\u003e\n\nThis guide shows you how to log events in your app.\n\n[Events](https://support.google.com/analytics/answer/9322688) provide insight on what is happening in your app, such as user\nactions, system events, or errors.\n\nAnalytics automatically logs some\n[events](https://support.google.com/analytics/answer/9234069) for you; you don't\nneed to add any code to receive them. If your app needs to collect additional\ndata, you can log up to 500 different Analytics Event *types* in your app.\nThere is no limit on the total volume of events your app logs. Note that event\nnames are case-sensitive and that logging two events whose names differ only in\ncase results in two distinct events.\n\nBefore you begin\n\nMake sure that you've set up your project and can access Analytics as described in\n[Get Started with Analytics](/docs/analytics/get-started?platform=web).\n\nLog events\n\nAfter you have configured the\n[`firebase.analytics()`](/docs/reference/js/analytics) instance,\nyou can begin to log events with the\n[`logEvent()`](/docs/reference/js/analytics#logevent)\nmethod. If you're already familiar with Google Analytics, this method is\nequivalent to using the `event` command in\n[gtag.js](https://developers.google.com/gtagjs/).\n\nTo help you get started, the Analytics SDK defines a number of recommended\nevents that are common among different types of apps, including retail and\necommerce, travel, and gaming apps. To learn more\n[about these events](https://support.google.com/analytics/answer/9322688)\nand when to use them, see [Recommended events](https://support.google.com/analytics/answer/9267735).\n\n**Note:** To get the maximum detail in reports, log the recommended events that\nmake sense for your app and their prescribed parameters. This also ensures that\nyou benefit from the latest Google Analytics features as they become available.\n\nYou can find implementation details for several events and their parameters in\nthe\n[gtag.js event reference](https://developers.google.com/gtagjs/reference/event).\n\nThe following example demonstrates how to log a `select_content` event: \n\nWeb \n\n```javascript\nimport { getAnalytics, logEvent } from \"firebase/analytics\";\n\nconst analytics = getAnalytics();\nlogEvent(analytics, 'select_content', {\n content_type: 'image',\n content_id: 'P12453'\n});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/analytics-next/index/analytics_log_event_params.js#L8-L14\n```\n\nWeb \n\n```javascript\nanalytics.logEvent('select_content', {\n content_type: 'image',\n content_id: 'P12453',\n items: [{ name: 'Kittens' }]\n});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/analytics/index.js#L20-L24\n```\n\nIn addition to the prescribed parameters, you can add the following parameters\nto any event:\n\n- Custom parameters: Custom parameters can be used as\n [dimensions or metrics](https://support.google.com/analytics/answer/10075209)\n in [Analytics reports](https://support.google.com/analytics/answer/9212670).\n You can use custom dimensions for non-numerical event parameter data and\n custom metrics for any parameter data better represented numerically. Once\n you've logged a custom parameter using the SDK, register the dimension or\n metric to ensure those custom parameters appear in Analytics\n reports. Do this via: *Analytics \\\u003e Events \\\u003e Manage Custom Definitions \\\u003e\n Create Custom Dimensions*\n\n Custom parameters can be used in\n [audience](https://support.google.com/firebase/answer/6317509)\n definitions that may be applied to every report.\n Custom parameters are also included in data\n [exported to BigQuery](https://support.google.com/firebase/answer/7030014)\n if your app is linked to a BigQuery project. Find sample queries and much more\n at [Google Analytics 4 BigQuery Export](https://developers.google.com/analytics/bigquery).\n- `value` parameter: `value` is a general purpose parameter that is useful for accumulating a key metric that pertains to an event. Examples include revenue, distance, time, and points.\n\nIf your application has specific needs not covered by a recommended event type,\nyou can log your own custom events. For example, if you're developing a game and\nwant to track when a player completes a particular goal, you could log an event\nsimilar to the following example: \n\nWeb \n\n```javascript\nimport { getAnalytics, logEvent } from \"firebase/analytics\";\n\nconst analytics = getAnalytics();\nlogEvent(analytics, 'goal_completion', { name: 'lever_puzzle'});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/analytics-next/index/analytics_log_event_custom_params.js#L8-L11\n```\n\nWeb \n\n```javascript\nanalytics.logEvent('goal_completion', { name: 'lever_puzzle'});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/analytics/index.js#L32-L32\n```\n\nView events in the dashboard\n\nYou can view aggregated statistics about your events in the\nFirebase console dashboards. These dashboards update periodically\nthroughout the day. For immediate testing, use the logcat output as described in\nthe previous section.\n\nYou can access this data from the\n[**Events**](https://console.firebase.google.com/project/_/analytics/events)\ndashboard in the Firebase console. This dashboard shows the event reports\nthat are automatically created for each distinct type of event logged by\nyour app."]]