Search code examples
google-analyticsgoogle-apigoogle-analytics-api

Google Analytics API how to get accountId by email


I need to revoke access from users, having an array of their emails.
I found some methods from the Management API to do so, but all of them use accountId as a user identifier. Could someone please tell me if there is a better approach than scanning all GA users with the /management/accountSummaries method, finding users with needed emails, and using their accountId to revoke access?

Thank you :)


Solution

  • Assuming i understand.

    1. you have access to a number of google anlaytics accounts.
    2. you have a list of user (emails) who may or man not have access to one or more of these google analytics acocunts
    3. you want to remove these users access.

    The only way to go about this would be to use the accountSummeries endpoint to get a full list back of all of the accounts you personally have access to.

    Then for each property i would run a profileUsersLinks.List to get a list back of all the users who have access to each of your properties.

    Once you find one that you want to remove you can simply run. ProfileUsersLinks.delete

    This is going to be a several step process as there is no other way of linking a email to a profile / account.