I have an application that fetches GA reports with API of users after they give us permission.
Added "useResourceQuotas" and it works fine. I can see quotas left. If a user doesn't use GA 360 there is a message stating the user is not eligible to use this parameter.
Is there a way to determine whether a user has GA 360 before I request a report?
Something from Management API maybe?
Currently I am using an empty report (with only dates) for that, but that looks like an ugly workaround.
You can fetch Google Analytics Account Summaries using Management API and check Web Property Level in the response i.e. webProperties[].level
It can be either STANDARD or PREMIUM where PREMIUM stands for GA360 web property.
Related
We have the following scenario:
Website A has GTAG installed and tracks every page visit, sending a internalUserId along in the dataLayer (when the user is logged).
Website B is a CRM where we list all users, and it uses the same database as Website A.
In the CRM we need to see what pages each of our users have visited.
Proposed solution:
Ideal solution: call Analytics API passing internalUserId and returning a list of pages the user visited.
Alternative 1: make Website A call an internal API that registers a visit, along with any other metadata. Unfortunately the dev team behind Website A wants to avoid this approach as it will send yet another request on every page, thus slowing the page down.
So the suggestion was to leverage analytics to gather this information.
Alternative 2: somehow instruct Tag manager to call an external API every time a visit occurs, and send along any meta data. I don't actually know if Tag manager offers this service or not.
The alternative 1 & 2 will mean that we will store the visit stats, while the ideal solution will use Analytics stats.
So the question is:
Does Analytics API offer the ability to query for a specific user identified by a custom property, internalUserId, that we set using dataLayer, and return that user's stats (visits) ?
Thank you very much
I don't believe you can query Google Analytics API using your internalUserId unless you set it as the user ID in GA, which may lead to limitations. You'd be better off merging the data by collecting the _ga cookie along with you internalUserID values. Look up all user activity by _ga and then merge to your CRM data with internalUserID.
I don't believe alternative 2 is possible.
Alternative 1 would require you store the data yourself and a client side call, but you'd avoid ongoing GA API usage. The calls from client side could be minimal. Use a Cloudflare worker to fetch and process only the data you need, that could be an interesting solution.
When i use personal reports in Google Analytics i see different numbers of users in the report than when i get them with API.
Support of GA answered, that this is ok, because system use different ways to count users in report when i use GA and in data which i got from API.
Is there any way to get same number of users by API, which i can see on site of GA in my personal report? Because now, when i try to get users with API for same period and with same dimensions i get different number of users, than i can see in personal report on GA site.
I need to test some things with a Google Analytics View, but the default demo account that Google offers does not allow user to use the Analytics Reporting API :
You cannot use the demo account with the Analytics Reporting API. Attempts to do so result in a permissions error: (403) insufficientPermissions.
Source
I just need to replicate a view with different data already.
Thanks for helping.
You cannot replicate views with data. A view will always start empty.
However you can simply register a Google Analytics account and send lots of bogus data (either by setting up a web page with tracking code and call it repeatedly, or set a cron job to fire call via the measurement protocol) (this will happen in realtime, so you need to wait a few days before you have enough useable data. There is not way to bulk-create hits for a longer timeframe).
If you just want to test the API it probably matter that much what data you use, so a mock account should work just fine.
I am attempting to bring Doubleclick Campaign Manager dimensions through the GA API and am getting the following error message -
"Restricted dimension(s): (DCM dimensions I entered in the query string) can only be queried under certain conditions. For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.
There is no guidance on that referencing site. Has anyone run into and solved this - or is it an auth restriction (shouldn't be: I have admin rights to the property).
thanks
If your property is not Google Analytics 360 you cannot query any of the metrics of the DCM. Take a look again here beside each metrics explanation there is the (Analytics 360 only). That is the only thing I can think if you also have admin rights on the property. Also check if you are authenticated with the correct account in any API or Query Explorer you are using
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.