Data Studio
3.8K members online now
3.8K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

This question is strictly about data studio, nothing related to Google Analytics or Adwords. And I literally have zero knowledge about Analytics.

I plan to create a report and share them to my co-workers. The data sources could be anything, say BigQuery, Cloud SQL or Sheet. But I want to present the information that is relevant to the current viewing user. So I probably need to determine the user id of the person who is viewing and filter data accordingly. I probably will need to have an mapping table, telling which user id is relevant to which keys of tables, somewhere that I can join and filter data. So the question is how do I do that in data studio? 

Data Studio: Filter data based on user id

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆

as far as I know, it is not possible yet. 

Data Studio: Filter data based on user id

Explorer ✭ ✭ ☆
# 3
Explorer ✭ ✭ ☆

You currently can't access User ID from Data Studio, so this isn't possible.

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Thanks Mimoune and Sian. I think you are right. Can't find the way to do that in Data Studio. But after spending some time digging around, I found a workaround. We can use the capability in the data sources to detect user ids. It's the viewer's credential feature. If set, the backend database can identify the current user. For example, SESSION_USER() function in BQ would return the user id.    

Re: Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi Pichai,

Could you please describe in more details how you manage to solve this challenge?

I have setup a Data View in BigQuery that filters a table on it's user ID. When added to Data Studio it works just fine.

 

But as soon as I share the report (and Data Studio data source) with the "viewer's credential feature" enable, that user get this error:

 

Error Details
You don't have access to the data set.
Error ID: 528c34a7

 

That user have access to the BigQuery data set. I also tried to use a standard table (instead of View) in BigQuery without the filter on SESSION_USER(). Still I get the same issue.

 

Did you manage to use "viewer's credential" feature for BigQuery? If so, how? Thanks!

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

I found the issue. Had to share access to the BigQuery project in GCP as well, not just the data set. Now it works great! Smiley Happy

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

You can't query data from the userId, but you can add it is a custom dimension with each hit and then query data off of that dimension. Simo Ahava has a great guide on this: Improve Data Collection with Four Custom Dimensions

 

As far as having a mapping table, there currently isn't a way to combine datasets in Google Data Studio, though they say they are working on that feature. However, you could create a function for a custom field that maps out the relationship and use that in your report. Here's Google's guide on custom fields: Conditional calculated fields

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

Hello Jon,

 

what kind of access or role should be provided for the user in GCP project? project viewer !!

what are the mandatory accesses that must be provided to the user to enable user_id based data restriction in data studio?

 

Thanks for your help!!

Data Studio: Filter data based on user id

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Hi Ashwin,

I don't really remember the access lever, but it was only to BigQuery. I suggest you test the few existing alternatives. The email of the Google user must existing in the data you want to filter with SESSION_USER().

 

Good luck!