Google Analytics - Service Account and Segments - api

I've created an app for Google Analytics in the API console. I am trying to list out custom segments that have been created, but have noticed that I cannot view existing Segments that have been created.
I followed this example: Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?
For instance, I log in to my google analytics account, grant access to a profile, then in the google analytics profile, I create a sample segment.
Calling this:
$service->management_segments->listManagementSegments();
I would expect to see my "test segment" but don't see it.
Is there an additional step that I would need to grant my service account the ability to see the custom segments setup?
This example here shows the custom segments:
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/segments/list
I am hoping someone can clarify the workflow. Thanks!

Since segments are tied to google accounts, not service accounts, they aren't available. It's best to grab segment definitions using the web server workflow, or use dynamic filters instead of segments.

Related

How to find which Google Cloud Project is associated with an instance of Google Classroom?

I'm trying to pull our Google Classroom data into a custom web application via the Google API Client (PHP). I was able to make a successful call using a service account set up in Google Cloud, but the call returned no Classroom data.
I'm assuming the Classroom data must be associated with a different Google Cloud Project, I'm just not sure which one. I don't want to create a service account for every single project and test them, there are too many projects. I've looked everywhere and I can't seem to find the answer to the question: how do I find out WHICH project a Google Classroom integration is associated with, so I can configure the API Client accordingly?
I tried looking through all Classroom settings to see whether there was any information about the Google Cloud Project being used to store the data. I tried contacting Google Support, but so far I've had problems getting an answer to my question.
Ultimately I just want to pull the Classroom data into our web application.
Thanks
To use a service account with google classroom api you must configure Domain wide deligation. This will allow the service account to impersonate a user on your domain.
$user_to_impersonate = "admin#yourdomain.com";
$client->setSubject($user_to_impersonate);
The service account will then behalf as though they were that person. It can then see everything that user has access to.
Without delegation in place the service account doesn't have access to anything.

How to integrate Google business messaging through API

Problems:
I am unable to enable Business Messages API, Because "Business Messages API" is not showing API list, While i am going to enable the API through the
https://console.cloud.google.com/apis/dashboard
I want to use auth token, while hitting the API, but the document is saying use the service.json for the credentials. i am following these doc. I am using "Google\Client()" with Laravel application.
https://developers.google.com/business-communications/business-messages/guides/how-to/agents?method=api
I am following these steps:
Login with google business account in the Dashboard
App taking multiple permissions as I have attached the permissions list and taking the auth token.
Open the chat box for the Business.
So please guide me, where i am going wrong. What is correct way to implement this.
Requirement:
I want to create a custom chat box for google businesses, Where business owner will login into the web app and He can easily manage the multiple business chats in one dashboard.
As per your given information, you have to be a partner of Google. As per google documentation, you need to be a partner of google and then you can create the agent and can send and receive messages. You can integrate the business messages API by following this documentation:
https://developers.google.com/business-communications/business-messages/guides
In this process, you need to be a partner of Google. The complete process is given on the link. If you follow this link, then you can use their built-in libraries easily and can send messages easily.
So far the permission for API, it might not be found for you because you might have to take permission for the particular project that is registered on google and then you will see the business messages API and you can enable it and use it. The reason as per the basic step:
https://developers.google.com/my-business/content/basic-setup
Sometimes, you have to submit the request form to take the API access for particular APIs. Or Share how are you using that API.
If you do not find a form for business messages API then you can ask for the information from bm-support#google.com. they mostly respond on a working day.

Another account access my Analytics API

I want to build a dashboard to my clients access your respective website analytics. But, after some research, I'm stuck.
Let's imagine the scenario:
My Analytics Account:
Client X - websitex.com
Client Y - websitey.com
In my dashboard, when the cliente Y log in, the data (pageviews) of websitey.com is shown on graphics.
But, there's a way to do that? By the moment, the only thing i got is retrieve information for my logged account (my analytics ID), not the information about another account.
There's a way to use the Google API, or, I'll have a "separate database" to save data each website?
Sorry, I'm really lost at the moment.
You can only view Google Analytics Accounts that you are authorized to view. For some reason this is a source of major confusion (seeing that your are not the first to ask), although it should be fairly self-evident.
If you want to see data from your clients account you have to ask your client to add your Google email to the GA account. If an email address is added to multiple accounts you can, via the API, choose between the accounts. Clientside authorization (OAuth2) will only work as long as somebody is logged in via a client application (usually a browser). The practial effect is that everybody who is authenticated via OAuth against Google will see only his own GA accounts, not other peoples data.
If you want a serverside application to pull data from various GA accounts you need a service account. But even the service account needs to be added to the GA accounts.
You can use the core reporting API, but the API will not give you access to accounts that you are not authorized to look at; your client needs to authorize you (or your applications service account).

How do I get Google Analytics data into a CMS without asking the user to authenticate?

I have a web application backend for my clients web site. Authorised staff can log in to the backend and view data.
I want to pull some data from Google Analytics to be viewed in the backend, but GA seems to insist that the user is logged in to their Google account themselves using OAuth2
I want to be able to authenticate the server not the user. They already have permission and it seems unnecessary and possibly intrusive to ask them to link their Google accounts to the GA account and possibly even have to create one first.
The server already has to supply a client id, client secret and an api key, so it's not as if there isn't already an authenticated connection.
I'm guessing that there must be a way to pass the Google Analytics account credentials to OAuth2 somehow but I am not that familiar with OAuth2
Is this possible and how would it be done. A simple example or a nudge in the right direction would be appreciated
There are similar questions around but the ones I have found do not answer my question in the way I need.
Yes you need to store the authentication, but you may be able to use Google Analytics Super Proxy for your needs. At the very least you can see its code on how it stores the authentication.
You authenticate once, input the data you need scheduled from the GA Reporting API, then take the data feed and use it to build charts in your intranet. Any user can view those charts without needing to login to GA themselves.

https://bigquery.cloud.google.com/ not connected. retrying

I am trying to work out query access to the Google Analytics API. I am not a developer and so progressing via the developer route is currently not an option (notes - https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide).
I have been looking at setting up with BigQuery, but am struggling to check that I can query in the web interface because it will not load for me.
I am logged in with the account that I am using to access our company URL (I can access this perfectly well using the GA interface).
I can also query the http://ga-dev-tools.appspot.com/explorer/ interface successfully.
What am I doing wrong? Do I need to go the whole hog and set up the bigquery billing (I am hesitant to do this since I want to prove the concept first).
Regards
Tristan
If you cannot access https://bigquery.cloud.google.com/, then I would work with your system administrator to verify that you have network connectivity to that web site.
If you can access the BigQuery UI, then you can follow the Sign Up for BigQuery instructions to enable the UI for you. You do not need to sign up for billing to run a few queries over the public sample tables, but you do need to sign up for billing if you want to load your own data into the system and to significantly increase your query quota limits.
As to BigQuery integration with Google Analytics Premium (see the blog post for background on this feature), you need to request this integration through Google Analytics Premium. Please contact your Google Analytics Premium customer support.