Displaying Analytics Dashboard for Clients using Google Analytics - google-analytics

We have certain amount of clients and each of us will have their pages on our website. We have to show them the analytics for their particular page. For this, we have the data on Google Analytics according to pages.
On the client admin page, they should be able to view the analytics for their page. This has to be coming from Google Analytics.
I have tried using the Core Reporting Api, but that needs an authentication and one should have access to Google Analytics profile, which is not possible for clients.
So now, Is there a way, where the client can see the dashboard with data being pulled form Google Analytics without any authentication?

No, authentication is required to pull data directly from Google. You could use one 'global' Google account and keep that account authenticated through code so that your users can access that data.
Only other option I've seen is to automate the export of the CSV data (via email) and have a routine that pulls off the CSV data and imports it into a system for public/private use - such as in your example.
Hope this helps!

Related

How can I use the Google Analytics API to pull GA Account Change History?

I want to be able to pull the Change History report from Google Analytics... any ideas/help would be much appreciated!
*It looks like the AdWords API offers this function, but I need it for the Analytics API
You can't. The relevant API for this would be the management API, but that does not list a function to get the account history, so you do not have programmatic access to that.
You could probably write a script using a bowser automation framework like Selenium that logs into Google Analytics using your own credentials, navigates to the account history, downloads the HTML content of the account summary page and then parses it to extract the desired information, but that would not involve the Analytics API at all (and is nothing that can adequately described in a Stackoverflow answer).

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

Get Google Analytics Data without Client Secrets

I am looking to make a web based app which creates a monthly report that has Google Analytics information in i.e. organic searches etc. Some clients will have their own Google Analytics accounts and wont be own mine.
I managed to get the OAuth 2 authorization working with my account however it wont work for clients as I needed to get the client_secret.json file from Google Developers website. I have seen a service like cyfe.com which just gets the google login information and outs the Google Analytics information in graphs and such.
Does anyone know how they manage this is possible without getting the client_secret.json file ?
oAuth2 is designed to let you access to users data with their permission, without requiring to access their password.
You should use your own client Id and client secret, these identify your application, not your users ("client" here means client of the API).
You then need to create an interface where users can allow your application to access to their data, from this you'll get an access token, allowing to your application to access to Google Analytics data of your user on their behalf.
Read "Using OAuth 2.0 to Access Google APIs", and identify the scenario that matches to what you want to achieve.
I strongly suggest that you use a library managing the authentication flow, you don't need to reinvent the wheel. Here's a list from Google: Google API Client Libraries.

Google analytics Embeded api with out Oauth authorize

How can i use gapi.analytics.auth.authorize without button..
I need it for customers, to track visits on their subdomain, and I have my analytics code on page, so they can't use button to authorize, need without it, automatically.
Any example?
Your question isn't very clear it is hard to understand what you mean by Button.
I think you mean that you would like to select data from YOUR Google Analytics account and display it on YOUR website.
To do this you will need to use a service account as apposed to Oauth2 (Oauth2 would popup with a new window requesting access). When you create the service account in the Google developer console take the service account email address. Give it access at the ACCOUNT level in the Google analytics admin section. It must be the account level this will then give the service account access to read your Google analytics data.
Quota: I am not sure what you are extending to do here but remember you can only make 10000 requests per day against your Google Analytics profile. After that you are cut off there is no way to extend this number. So I advice you to save the data in the database someplace you shouldn't request the same data more then once.
Example:
I suggest that you look for an example in what ever programing language you are intending to use. Again your question doesn't state anything about what language you will be using. Hello analytics API might be a good place to start but it depends upon the language the PHP one is way out of date I wouldn't bother with it. Also you cant use a service account with JavaScript so that one is out to.
Update figured out button
Embded api I think I have finally figured out what you mean by button. gapi.analytics.auth.authorize is used in the Google analytics embedded api. Which is JavaScript which it is not possible to use with a Service account. So the final answer to your question is
Answer: You cant remove the button from the Google Analytics Embded api the only way to login with JavaScript is to use Oauth2.
Advice: switch to PHP and use a service account to request data yourself. Or give each of your customers access to your Google analytics so they can login themselves.

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