Get XXXXX#developer.gserviceaccount.com as a service account - google-analytics

I am new to Google Analytics and I am trying to retrieve Google Analytics data using Pentaho Data Integration (CE 6.0) by following Pentaho Google Analytics
It says I need to create a service account to get the data. On the google developer console I at location Google API manager --> Credentials --> Create service account
Now when I try to create a new service account, it by default assigns XXXXX#YYYY.iam.gserviceaccount.com
Instead of this I must have XXXXX#developer.gserviceaccount.com
Can someone please share any insight on how to get XXXXX#developer.gserviceaccount.com as a service account email?

The old format for service accounts was
XXXXX#developer.gserviceaccount.com
the new format for service accounts appears to be
XXXXX#{projectId}.iam.gserviceaccount.com
you will probably not be able to create one with the old format just go with the new format

Related

Get access to clients data using API

Is it possible to make a platform where client can sign up and log in using their Google accounts, and accept that their Google Analytics data will be used for calculations.
They should accept the use only once, and then the program should download and process the Google Analytics data every day.
Please point me in the correct direction for documentation
Yes, you need to create a project in Google Cloud Platform, then go to : API and Services > Library > Google Analytics API. (This is to get analytics from an user). Then you need to create a project inside Firebase, allowing email authentication and you will be able to do your task.

Analytics API: I can't use two different API credentials on my PC

I've 2 different API keys enabled on 2 different accounts. One professional and the second private and I don't want to link the 2.
My problem is that I've been working with the professional API credentials for almost 3 months and everything works fine. Now, I've created a new account with a new Analytics account and my problem is that I can't use the new API directly with my new Analytics account.
I can't make my script to authorize the new user and I receive an error that says that the user does not have sufficient permissions for this profile.
I managed to make it work by adding my private account as a user in my professional Analytics account. It seems like I can't make another account authorization even if I'm using a different API created on another account. It's like the connects to the first account authorized on my PC.
Is there any way to reset the authorization on my PC each time I want to use one of the API?
Thank you,
EDIT: I'm running a Python script that uses the Analytics API and the only time I have a prompt to authenticate it's the first time I use the application on a new PC. After that, the script runs without any prompt, The credentials are those of the API (client ID and Client secret) and I'm not using them directly but I'm using the client_serets.json file generated on the Google dev console.
I have figured it out. You'll have to navigate to this url https://myaccount.google.com/permissions?pli=1 and remove the service you want to remove.

Is it possible to create Service account and get p12 key programmatically for google accounts?

I need to extract Google Analytics data through it's API. However I do not want to generate any account and key manually (the reason is I do not want to let this technical this to be performed by any non-techie person) and want to dump that data for analysis purpose.
In order to use any of Googles APIs they need to know who you are. You as a developer are identified by the project you create on Google Developer console. Once the project is created you can create a number of different types of credentials including Service account credentials and Oauth2 Credentials.
Answer: No there is no way to programmaticlly create service account credentials. Nor is it possible to use the a Google api without first creating a project on Google developer console.
Note: Google Cloud Resource Manager does exist but is very limited in what it allows you to do.
If someone else is going to be running your application to access their Google analytics Data you should idealy be using Oauth2 in your application and not a service account.
Service accounts are designed as way for the developer to grant others access to data owned by the developer in question. They are not really intended for novice users to be creating their own projects on google developer console and generating credentials.
You are basically asking if you can obtain the credentials necessary to query the API via the API. This does not work.
I am also not sure how this would help you. Before you can do any API operations to a Google Analytics account you need to have an authorized user (e.g. a service account) added to your view or property. If you are in a situation where you can add a user programmatically to an account you might as well just read the data you need.

It is possible to create a script for generating new sites on a google analytics account?

I need to create a script (php for example) to generate new sites on a google analytics account.
I need to obtain the ID of the generated site.
¿It is possible to do it? How can i achieve it?
Thanks
No. All of the Google Analytics APIs are read-only. The only way to create new accounts is manually.
As #jk added below, from the Google Analytics Management API docs:
Google Analytics provides developer access to the configuration data
through the Management API, which is a read-only API for account and
configuration data.

How can I generate a GA tracking code programmatically?

How to generate Google Analytics tracking code programmatic-ally?
I am new to Google Analytics API, can someone please help
It is NOT possible to create new Google Analytics accounts or profiles programmatically using the existing APIs.
There are two APIs available, the Data Export API and the Management API. However, they are bot read-only.
With the Google Analytics Data Export API, you can develop client applications to request data from an existing Analytics profile for an authorized user, and refine the results of the request using query parameters. Currently, the Data Export API supports read-only access to your Google Analytics data.
Currently, the Management API supports read-only access to five components of the Google Analytics Management system: Account data,Profile data, Web property data, Goal data, Advanced segments
Seems like it's finally possible in 2021 with alpha api.
https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties/create#authorization-scopes
It's not currently possible to create Google Analytics accounts automatically at the moment but generating the tracking code is possible.
The only real variation between the tracking code generated each time you create a profile for a new domain is the web property ID. This is in the format UA-XXXXXXX-X. Each X is a number - the first 7 numbers are the account number and the number after the last dash relates to each web property set up for the account.
You can use the accounts feed of the API to get a list of accounts and their profiles. If an account only has one profile then it's possible to use the web property ID of it to automatically generate the tracking code. However, if there's multiple web properties then you would need a way to decide which one to use (present the user with a selection list etc).

Resources