Hello Urabe of Oz vision.
If you are operating a web service, many companies may be using Google Analitycs to look up various indicators such as KPIs.
This time, there was a request (my w) to calculate the main OS version and browser for the hapitas test displayed in the hapitas help as easily as possible, and I was able to satisfy it by using Re: dash. ,to introduce.
I also prepared a sample code for the calculation in gist, so please use it as soon as you like.
--Until now, in order to calculate the OS to be tested for PC test browser, iOS, and Android by the following procedure, it was downloaded from GA as CSV, processed with a spreadsheet, and calculated. Let Re: dash calculate this calculation. Make sure that anyone can get the correct information at any time.
I wrote this on the wiki. (Troublesome manual work)
10.0.0 (A.B.C)
, of which ʻA. Major versionand
B. Minor versionare rounded and totaled. Don't look until
C. Maintenance version`--Re: dash version 5 and above --Google Analytics, Python can be selected as the data source --Python is lightly touched --Environment and authority - A --You have permission to create a GCP service account and enable the Google Analitics API. --You have permission to add the above GCP service account as a user in Google Analytics --Re: You can create a data source with dash privileges and register the json key file of the created service account. - B --Even if you do not have the authority, the environment to which the above settings are applied is complete.
--Construction of Re: dash environment --Google Analytics settings --Data source Google Analitics, Python settings
https://gist.github.com/oz-urabe/e8e7abf5fdd748a8a2394ac6d17f503b Select a Python data source and create a query for it.
Of these, the json format query at the beginning does not work if you write the ids as ga: 66453283
. Please enter your GA id.
query = '''
{
"ids": "ga:66453283",
"start_date": "30daysAgo",
"end_date": "yesterday",
"metrics": "ga:users",
"dimensions": "ga:operatingSystem,ga:browser",
"sort": "-ga:users"
}
'''
Also, although it is described as follows, since the data source name is Google Analytics
in Hapitas, it is described like this, but the data source name of Re: dash used isdepending on the person
I think it's GA`, so it's okay if you can match it.
data = execute_query('Google Analytics', query)
https://gist.github.com/oz-urabe/795ae3189c4115e14dad038cfa6e3b49 Select a Python data source and create a query for it.
It is the same as the ids and the data source name to be modified according to the environment.
There is an additional " filters ":" ga: OperatingSystem = ~ iOS "
, but this is a filter by OS name. When aggregating on Android, use " filters ":" ga: OperatingSystem = ~ Android "
.
query = '''
{
"ids": "ga:201135853",
"start_date": "30daysAgo",
"end_date": "yesterday",
"metrics": "ga:users",
"dimensions": "ga:operatingSystemVersion",
"sort": "-ga:users",
"filters": "ga:OperatingSystem=~iOS"
}
'''
The result of registering and executing these queries will be as follows. (Dashboard)
@terra_yucco helped me create a query for GA. Thank you very much!