How to retreive session data from Google Analytics Real-time API? - google-analytics

I am looking for a way to get the most up to date possible sessions from Google Analytics.
The standard Google Analytics API as you are probably aware can be hours out of date. I had a look at the realtime dashboard and can't seem to find an rt:sessions/visits. rt:pageviews is close but doesn't give me quite what I need, has anyone found a combination of dimensions/metrics to get realtime sessions from the realtime api?
Thanks!

Google analytics standard reports can take between 24 and 48 hours to complete processing the Google Analytics API (reporting v4 and core v3) are reading from the same data as the Google Analytics standards reports. If the data has not completed processing there is no way for you to get the data. The google analytics api v4 does have a new field in the response called isgolden which will tell you if the data you have requested is done processing or not.
isDataGolden boolean Indicates if response to this request is golden
or not. Data is golden when the exact same request will not produce
any new results if asked at a later point in time.
The Realtime api is very limited in the data that you can get. As you have already stated is a limited number of dimensions and metrics available (Session count is not available only active users). This is due to the fact that these are the ones that processing is not needed on so the data is available for the API to return you. There is also a limitation that I think the Realtime api only contains data over the last five minutes.
There is no other way of getting the data out any faster

Related

How can I fetch the number of pageviews per page on my site in the last 30 minutes with google analytics?

I would like to add a "what other people are doing" section to my react website, which shows the currently most interesting sections of my website using google analytics. This means I would need fetch the most popular pages every 30 minutes from google analytics from within my pages backend, presumably using the realtime api, because I know that the reporting of the reporting API can be up to 24 hours out of date.
But unfortunately, the realtime API seams to only be able to track users that are using the page currently, and there doesn't seam to be a way to distinguish which actual page there on.
Basically what I need is a way to figure out how many individual people (not just people refreshing over and over again) have visited a certain section of my page in the last 30 minutes. Google analytics seams to be the way to go but I'm open to any other solution, as long as it can be used from within the aws cloud.
What you need to remember is that the Google Analytics website also uses the Google Analytics API. If something you want to see can be done on the website for the most part you can also do it with the api, with the exception of a few of the calculated metrics which can be a bit tricky to duplicate with the API.
The reporting of the Google analytics Reporting API takes between 24 - 48 hours to process your data until that time your data will not be completed processing so the numbers will not be correct.
The google analytics real-time api would be an option but the data is limited into how long it stays around as well is what dimensions and metrics you can actually view as they are only giving you access to what they are sure has completed processing.
An issue with both of these solutions would be the quota, every view on google analytics is only allowed to make 10k requests per day. You will need to ensure that you stay within this so if you are only requesting data every thirty minutes around the clock you should be able to keep this to around 48 calls but its wroth noteing.
IMO Google analytics is not suited for this task you should keep a running count on your own website store it in the database and use that.

Delay issue in analytics reporting api v4 - Google analytics

I am facing delay issue while fetching data from google analytics using analytics reporting api. sometimes it prints incomplete data(when I tried to fetch data from past 10-20 minutes.) Does anyone have idea how much delay does this api takes to reflect data from view and how to resolve the issue of incomplete data ?
Processing latency is 24-48 hours, if you want to obtain stable data you have to refer to those of the previous 48h.
https://support.google.com/analytics/answer/1070983?hl=en

How to get/show the total website visits from google analytics?

We are using google analytics on our website to record the statistics. however, we need to show the total visits is it possible to show from google analytics API? TIA
Im not sure where you want to show the total visits but if its on your website you need to remember a few things about the Google Analytics api.
The first being that there is a data latency which means that it takes between 24 -48 hours for your data to complete processing. If you attempt to request say the current visits for today then the number will not be correct. You could request the number of vists for say three days ago and get back a number that is stable.
The other issue you are going to have is with quota. If you intend to load this from the API everytime a user visits your website they you will quickly run out of quota as you can only make 10k requests against a view in a single day so depending upon how many times this page is loaded this may not work for you.
An idea would be to load the data once at night and store the data in your database some place and then load from that as then you are only making a single request to the api and are unlikely to run out of quota.
Google anlaytics reporting api v4
Yes, just get ga:sessions metric defining the time interval that interests you.
Core Reporting API: https://developers.google.com/analytics/devguides/reporting/core/v3/common-queries
The Dimensions & Metrics Explorer lists: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/

Bigquery backfill table from Firebase Analytics [duplicate]

I have setup Firebase analytics data to BigQuery. However I received my first export today and it contains all yesterdays user statistics. That is great but I need lifetime statistics history or at least last month's data.
Do I already have access to my entire historic analytics data threw Big Query but I and I do not know how to access it? If so can you point to documentation or give a quick walk threw?
Is it even possible to get the full (or at least a longer period than a day) historic analytics data?
Bonus question: Can I directly access data that is used in Firebase analytics console? They should be feeding it with some API for some things I need aggregates would be sufficient. So is there http://analytics.firebase/data.json I could access while logged in to my Firebase account to save data to my machine?
firebaser here
Firebase Analytics does not expose the historical event level data. It only exposes aggregate information.
Complete event data is only available from the moment you enabled the BigQuery connection. No data from before that time will be added to BigQuery.
The data from the analytics reports that is shown in the Firebase Console is available through the Analytics Data API. See Is there any api for dashboard analytics data?

How to get an export of firebase analytics full historic data?

I have setup Firebase analytics data to BigQuery. However I received my first export today and it contains all yesterdays user statistics. That is great but I need lifetime statistics history or at least last month's data.
Do I already have access to my entire historic analytics data threw Big Query but I and I do not know how to access it? If so can you point to documentation or give a quick walk threw?
Is it even possible to get the full (or at least a longer period than a day) historic analytics data?
Bonus question: Can I directly access data that is used in Firebase analytics console? They should be feeding it with some API for some things I need aggregates would be sufficient. So is there http://analytics.firebase/data.json I could access while logged in to my Firebase account to save data to my machine?
firebaser here
Firebase Analytics does not expose the historical event level data. It only exposes aggregate information.
Complete event data is only available from the moment you enabled the BigQuery connection. No data from before that time will be added to BigQuery.
The data from the analytics reports that is shown in the Firebase Console is available through the Analytics Data API. See Is there any api for dashboard analytics data?

Resources