Can Management API be used to create a Google Analytics Account? - google-analytics

Suppose that a user has a Google account (say a Gmail account), but he does Not have a Google Analytics account.
Can we have a 3rd party application use the Management API (when the user is willing to authenticate it via OAuth2 using his Google account) to reach the stage of creating Tracking Code ?
I am asking this because, in https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/ , only 'list' is the method that is available for Accounts.

It doesn't appear that you can create a fresh GA account from the Management API. You can, however, list, create, edit, and delete users from an existing GA account:
User Permissions in the Management API allows you to list, create, edit, and delete users from your Google Analytics account. This is useful if you want to automate adding new users to Google Analytics, or removing a set of users.
User Permissions - Developer Guide
Add a Single User

Related

Google analytics API - how to create new account

Okay, some heads-ups as I feel I'm an idiot and missing some simple stuff. As far as I understand Google Analytics works with a 3 tiers system: account -> property -> view. and I should be able to manage these 3 levels via the google analytics management api.
For some context as to why I encounter this issue. I am making a CMS in which I want to register a new google analytics account per user, and a property per website this user has. (implementation and usage of views out of scope for now, I will implement those on a later date). To achieve all of this I started following Google's documentation on the Google Analytics Management API (according to Google this is what manages accounts, properties and views). Therefor I have made a service-user-account which should have enough permissions to manage GA-accounts.
However I can't seem to be able to create a new account via the API. Am I missing something obvious? Is it not possible at all this way? If so, how then? Because my goal is to have GA on every website, without the user having to config anything.
You can't do it. The management API only allows for the list operation on accounts: https://developers.google.com/analytics/devguides/config/mgmt/v3/account-management#account_summaries
The only solution would be to use the Provisioning API. It can be used to create new Google Analytics accounts and enable Google Analytics for your customers at scale: https://developers.google.com/analytics/devguides/config/provisioning/v3/
Anyway, the Provisioning API is currently available by invitation only.

Maximum connected Accounts in Analytics

we are using a iam.gserviceaccount.com Email adresss to connect our tool with the Google Analytics accounts from our clients.
We have reached the maximum connected accounts, but an upgrade is not possible because we can't response to the emails sent by analytics support.
Is there another way to upgrade it? Or is there another possibility to connect our tool with the analytics API?
We already tried to upgrade the account with the analytics support, but it is not working because of the emailadress.
For normal Google analytics accounts there is a limit to 100 accounts that you can have access to. If you upgraded to a premium account if i remember correctly that number jumps to 250.
You are currently using a service account and granting it access to a number of Google analytics accounts. The service account is going to be bound by the normal user limit of 100 and your not going to be able to increase that.
The problem is that you are using service accounts in correctly. Your not supposed to be giving the service account out to your customers and asking them to add it as a user on their Google analytics account. Service accounts are intended to be used by developers and companies that have access to data and want to share that data with others.
You should be using Oauth2 to gain access to the users data and saving the refresh token in your application which will enable you to request data for the user when ever needed.
By using a service account you are going to be hit with a lot of quota limits because they are shared by the user a user can only make so many requests so fast per day. By using Oauth2 you would be using different users and would not have as many issues with the user based quotas.

How to change owner of site on Google Analytics?

How to change owner of site on Google Analyics?
My site was maintained before by some company (Company A) that created site, targets in Google Analytics. But now my site maintain another company (Company B) that havent access to Google Analytics.
Can I transfer site, data, targets from old account GA to new account (Company B)? I havent access to old account (bcs owner is another company (Company A), I dont collaborate with them).
You will need to gain access to the old account and follow the account transfer process: https://support.google.com/google-ads/answer/44500?hl=en
If you don't have access or can't gain access, the best you can do is create a new account with this property and add the new code to your website, thus losing your past data.
The process to move a Google Analytics property is a bit clunky, but pretty slick once you've had to do it a few times.
A user will need Admin access to the Google Analytics ACCOUNT where the Property is currently, AND Admin access to another Google Analytics Account (create a new one if you need to) where you want to move the Analytics Property to.
Once you have Admin access to both, head in to the Property Settings and click, "move account".
On completion, you can update the access rights to your Google Account, removing access as necessary.
Your Analytics Property will be complete with all of the historic data, configuration and user access rights.
There's a video showing the process here too: https://youtu.be/m_F3qmSTIl0

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.

Google Analytics: updating multiple accounts

I have account that has 100 accounts, I've added a Google Service account (I can't use anything else because of 3rd party app limitation) and now I need to allow it to access all of these accounts. Seems there's no way at Google Analytics UI to do that and I will have to manually edit 100 accounts.
Is there any better way to do it? Maybe something like AdWords Editor just for Analytics?
If you have a Google User Account that has access to all the Google Analytics Accounts (which is how I interpret your first sentence) you can bulk edit them via the Google Analytics Management API, and that includes adding users that might or might not be service accounts. A reasonable easy way would be to use a Google Spreadsheet and some Google Apps Script. The script will run as the user that is currently logged in to Google and will be able to access all Analytics account that user has access to.
However you need to have necessary permissions to edit the GA accounts, so if you do not already have an authorized account you will (unsurprisingly) not be able to add one

Resources