Search code examples
google-analyticsgoogle-analytics-apisaas

How can I get my customers' Google Analytics data?


I want to create a SaaS, for this I need my customers' Google Analytics data. Can I do this? Is something like this possible? I found the Management API, but I don't know if I can do it, I don't even understand it. Thanks


Solution

  • In order to request Google analytics data you need to use serval different apis. But the first thing you need to understand is that there are two versions of google analytics these days Universal analytics and Ga4. They are not interchangeable.

    Universal analytics

    The management api will give you access to see what universal analytics google analytics accounts that the user has access to. This is just the accounts and users. It is not the data itself within a universal analytics account.

    To see the data within a universal analytics account you need to use the Google analytics reporting api. This api will allow you to extract universal analytics data on behalf of your users.

    Ga4

    As for the GA4 accounts. you would need to use the Google analytics admin api to access account information. The Google analytics data api will give you access to the data within a GA4 account.

    Note: at the time of writing both of the GA4 apis are still in Beta.

    authorization.

    All of these systems will require that you have the consent of a user on the account in order to access their data. So you will need to implement Oauth2 authentication and request access with the appropriate google analytics scope.