[null,null,["上次更新時間:2025-08-23 (世界標準時間)。"],[],[],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."]]