Search code examples
firebasegoogle-analyticsfirebase-analyticsgoogle-analytics-firebase

Can user properties be arrays in Google Analytics?


I have a website where one user can have many roles (e.g., "merchant", "customer", "admin"). These roles can be combined in any combination (e.g., users can be a "merchant" and a "customer"). Ideally, I'd like to filter analytics data by these roles.

Can I create a user property that's just an array of these roles?

firebase.analytics().setUserProperties({ roles: ['merchant', 'customer'] })

I realize that I could split this out into multiple properties…

firebase.analytics().setUserProperties({ isMerchant: true })
firebase.analytics().setUserProperties({ isCustomer: true })
firebase.analytics().setUserProperties({ isAdmin: false })

… but that would get messy as the number of roles grow. I'd prefer to use an array if possible.

Metadata

  • Google Analytics 4
  • Firebase 8.2.6

Solution

  • The value of property will be interpreted as a string not as an object or array.