Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Google Analytics tiene una llamada setUserID, que te permite almacenar un ID de usuario de la persona que usa tu app. Esta llamada es opcional y, por lo general, la usan las organizaciones que quieren utilizar Analytics con BigQuery para asociar datos de estadísticas de un mismo usuario en múltiples dispositivos, apps o proveedores de estadísticas.
Existen muchas maneras de crear IDs de usuario válidos. Una forma es asignar un identificador y que solo tú puedas hacer un seguimiento hasta el usuario específico. Como posible ejemplo, considera a un desarrollador hipotético de juegos para dispositivos móviles, AwesomeGameCompany, que cuenta con su propio AwesomeGameCompanyID interno que crea para cada usuario. Si una organización externa no puede hacer un seguimiento de AwesomeGameCompanyID hasta el usuario original, esta podría usar AwesomeGameCompanyID o, mejor aún, generar una versión con hash de AwesomeGameCompanyID como el valor de ID de usuario para Analytics.
Esto permitiría calcular valores como el gasto total de cada usuario en todos sus juegos.
No es necesario configurar un ID de usuario para que Analytics funcione correctamente.
Si solo te interesa buscar eventos que pertenezcan al mismo usuario de la misma app en un solo dispositivo, puedes usar user_pseudo_id.
Analytics genera este valor automáticamente y se almacena en BigQuery para cada evento.
Configura el ID de usuario
Puedes configurar un ID de usuario con el siguiente método:
Swift
Nota: Este producto de Firebase no está disponible en el segmento de macOS.
Analytics.setUserID("123456")
Objective-C
Nota: Este producto de Firebase no está disponible en el segmento de macOS.
Después de configurar el ID de usuario, todos los eventos futuros se etiquetarán automáticamente con ese valor y podrás acceder a él si consultas el valor user_id en BigQuery. Agregar un ID de usuario no afectará ningún evento que haya registrado Google Analytics.
Si quieres obtener más información para acceder a los datos de Analytics en BigQuery, consulta esta guía para desarrolladores.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-05 (UTC)"],[],[],null,["Google Analytics has a `setUserID` call, which allows you to\nstore a user ID for the individual using your app. This call is optional, and\nis generally used by organizations that want to use Analytics\nin conjunction with BigQuery to associate analytics data for the same user across\nmultiple apps, multiple devices, or multiple analytics providers.\n| **Note:** You are responsible for ensuring that your use of the user ID is in accordance with the [Google Analytics Terms of Service](https://www.google.com/analytics/terms/). This includes avoiding the use of impermissible personally identifiable information, and providing appropriate notice of your use of identifiers in your Privacy Policy. Your user ID must not contain information that a third party could use to determine the identity of an individual user. For example, you cannot use a user's email address or social security number as a user ID.\n\nThere are many ways you can construct valid user IDs. One approach is to use an\nidentifier you assign and only you can track back to an individual user. For one\npossible example, consider a hypothetical mobile game developer,\nAwesomeGameCompany, that has their own internal `AwesomeGameCompanyID` that they\ncreate for every user. If it isn't possible for an outside organization to track\nthat `AwesomeGameCompanyID` back to the original user, they might consider using\nthat `AwesomeGameCompanyID` --- or, better yet, a hashed version of\n`AwesomeGameCompanyID` --- as the user ID value for Analytics.\nThis would then allow them to calculate values such as a user's total spend\nacross all of their games.\n\nSetting a user ID is never required for Analytics to work correctly.\nIf you're only interested in finding events belonging to the same user for the\nsame app on a single device, you can use the `user_pseudo_id`.\nThis value is generated automatically by Analytics and is\nstored within BigQuery for each event.\n\nSetting the user ID\n\nYou can set a user ID with the following method: \n\nSwift\n\n\n**Note:** This Firebase product is not available on the macOS target. \n\n```swift\nAnalytics.setUserID(\"123456\")\n```\n\nObjective-C\n\n\n**Note:** This Firebase product is not available on the macOS target. \n\n```objective-c\n[FIRAnalytics setUserID:@\"123456\"]\n```\n\nAndroid \n\n```java\nmFirebaseAnalytics.setUserId(\"123456\");\n```\n\nWeb \n\n```java\nimport { getAnalytics, setUserId } from \"firebase/analytics\";\n\nconst analytics = getAnalytics();\nsetUserId(analytics, \"123456\");\n```\n\nWeb \n\n```java\nfirebase.analytics().setUserId(\"123456\");\n```\n\nDart \n\n```dart\nawait FirebaseAnalytics.instance.setUserId(id: '123456');\n```\n\nUnity \n\n```c#\nFirebase.Analytics.FirebaseAnalytics.SetUserID(\"123456\");\n```\n\nC++ \n\n```c++\nanalytics::SetUserId(\"123456\");\n```\n\nAfter setting a user ID, all future events will be automatically tagged\nwith this value, and you can access it by querying for the `user_id`\nvalue in BigQuery. Adding a user ID will not affect any\nevents previously recorded by Google Analytics.\n\nTo find out more about accessing Analytics data in BigQuery, please see\nthis [development guide](https://cloud.google.com/solutions/mobile/mobile-firebase-analytics-big-query)."]]