We are using Analytics Reporting API v4 in our backend to process analytical data collected from our clients (apps & website). We are facing an issue that the reporting API requires a viewId parameter to be present in the request that queries analytical data, otherwise the request fails.
// create the ReportRequest object
ReportRequest request = new ReportRequest().setViewId("your-view-id-here")
.setDateRanges(Arrays.asList(dateRange))
.setDimensions(Arrays.asList(browser))
.setMetrics(Arrays.asList(sessions));
According to their documentation, the viewId parameter can be extracted from the Google Analytics Console, which is correct.
The problem we are facing is that our "Website" property in Google Analytics already has a view where we can extract the ID from under it's settings:
This is great and exactly what we need, but for the "iOS" and "Android" properties, there is no view and the button to create one is greyed out:
Is there any way to query the API without specifying a viewId or is there a way to create a view in the console that we are unaware of?
Could the issue be caused by the fact that we are using Firebase to collect our data in Android and iOS?
Related
I'm using the documentation https://developers.google.com/admin-sdk/reports/v1/guides/push#making-watch-requests for creating the channel for team drive for google using google reports API. According to the document, we can make channel depending upon various filter conditions. For my purpose, I choose to use the filter "owner_is_team_drive==true". The problem with using this filter is that a channel gets created properly (I get a channel object in return) but the notification doesn't come if I perform any action.
I'm using Google Admin SDK for reports for creating the request for the channel. While looking at the logs I found that the API being used to hit the request is https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/drive?filters=owner_is_team_drive%3D%3Dtrue
PS: I tried using other filters(like "doc_type==team_drive") and also the API without filters, I get the notification properly.
I'm using the documentation https://developers.google.com/admin-sdk/reports/v1/guides/push#making-watch-requests for creating the channel for team drive for google using google reports API. According to the document, we can make channel depending upon various filter conditions. For my purpose, I choose to use the filter "owner_is_team_drive==true". The problem with using this filter is that a channel gets created properly (I get a channel object in return) but the notification doesn't come if I perform any action.
I'm using Google Admin SDK for reports for creating the request for the channel. While looking at the logs I found that the API being used to hit the request is https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/drive?filters=owner_is_team_drive%3D%3Dtrue
PS: I tried using other filters(like "doc_type==team_drive") and also the API without filters, I get the notification properly.
There is an API in place and available to me (v4 compatible), but for various reasons it's not working correctly and there is not much time to fix it (too many other fires). So the idea was floated that that to bypass most of the issues with API here it might be a quick-fix to send whole query to GA.
It needs to be automated and results stored in our DB (Webservice on MS Stack), else we would do it manually all the way, which is out of the question at this time.
Hence the question:
IS there a way to submit a query that is exactly the product of a Query Explorer via API or any other way and retrieve it's results?
The API Query URI returned by the Query Explorer
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A78110423&start-date=30daysAgo&end-date=yesterday&metrics=ga%3Ametric1
Is for the Google Analytics v3 api. To use this in your own code you must simply attach a valid access token to the end of the request.
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A78110423&start-date=30daysAgo&end-date=yesterday&metrics=ga%3Ametric1&access_token=XXXX
This is not going to be using the Google Analytics v4 API that is a different call entirely.
Access tokens can be retrieved from either service account authentication or Oauth2 authentication and must be valid for the view you are requesting data for.
I am currently querying my Google Analytics data using the Google Analytics API via R.
I would like to query based on the unique client ID as my primary dimension, but I can't find this dimension using the API.
Is it possible to query Google analytics from the API using the client Id as a dimensions?
Update: Client ID is now available in Google Analytics Core Reporting api as ga:clientId.
I've added it in my script and works seamlessly.
Query explorer doesn't support it yet, hopefully soon...
The only dimensions and metrics that you can use with the Google Analytics API can be found in the Dimensions and metrics explorer you could also check the metadata API.
As you can see client id is not a valid dimension exposed via the Google Analytics API. You could set this in a custom dimension yourself however for it to work your going to have to make sure that its set on every single request you send to Google Analytics.
then you can use the custom dimension metadata
update
As of late 2018 early 2019 it is now possible to query ga:clientid from the google analytics api.
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).