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
Related
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/
I've got an API query that pulls Acquisition/Channel data by day, users, sessions, bounce rate, etc. Historically, I tie out exactly to the data shown at the GA site.
I've built a new report that analyzes our same-day sales, and find that all my numbers are much higher than that shown on the GA site. This was the situation yesterday, and now my data, pulled this morning, ties out.
I haven't seen the GA site update our numbers in hours, but my GA API data is changing on each pull.
Is this expected behavior? Have others seen similar things?
Data going into GA and pulled from the API is not real-time. There is a processing latency with data processing that could be 24-28 hours.
Here i have got JSON values from this i have used in query core explore but i got 0 value
{"kind":"analytics#gaData","id":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:181407717&metrics=ga:pageviews,ga:uniquePageviews&start-date=7daysAgo&end-date=today","query":{"start-date":"7daysAgo","end-date":"today","ids":"ga:181407717","metrics":["ga:pageviews","ga:uniquePageviews"],"start-index":1,"max-results":1000},"itemsPerPage":1000,"totalResults":1,"selfLink":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:181407717&metrics=ga:pageviews,ga:uniquePageviews&start-date=7daysAgo&end-date=today","profileInfo":{"profileId":"181407717","accountId":"125404806","webPropertyId":"UA-125404806-1","internalWebPropertyId":"183966900","profileName":"All Web Site Data","tableId":"ga:181407717"},"containsSampledData":false,"columnHeaders":[{"name":"ga:pageviews","columnType":"METRIC","dataType":"INTEGER"},{"name":"ga:uniquePageviews","columnType":"METRIC","dataType":"INTEGER"}],"totalsForAllResults":{"ga:pageviews":"4","ga:uniquePageviews":"2"},"rows":[["4","2"]]}
totalsForAllResults":{"ga:pageviews":"4","ga:uniquePageviews":"2"},"rows":[["4","2"]]}
Your request appears to returning results just fine. if these aren't the numbers you were expecting then you may want to consider the following as you have added today in your request.
The Google analytics core reporting api is for extracting data from Google analytics it is not intended for extracting resent data from Google analytics as It takes 24 - 48 hours for the data to be processed on the servers.
Data latency
Data processing latency
Processing latency is 24-48 hours. Standard accounts that send more than 200,000 sessions per day to Analytics will result in the reports being refreshed only once a day. This can delay updates to reports and metrics for up to two days. To restore intra-day processing, reduce the number of sessions your account sends to < 200,000 per day.
Try doing the same request but do it for a few days ago. or try using the Google antlyics realtime api which only displays the last five minutes of data give or take.
I know Google Real Time Data provided event data that just happened. But two questions that didn't get answer anywhere are :-
If I fire an event from client (web, app etc), then after how much time should I fetch real time analytics data through Google Real Time Client API?
How much old is the data which we get from API? The events data which I get from API is at max 5 mins older? 10 mins older? or something else? To be more clear let there are following events triggered from client:-
<event1> fired just now
<event2> fired 1 minute before
<event3> fired 2 minutes before.
<event4> fired 10 minutes before
Then when I request Real Time Analytics API, will I get all three events? or some of them get lost? If lost then what is the threshold time after which event will not be counted as Real Time?
The response from the real-time API returns information about what is going on on your website now. What is now has never been defined officially by Google. However in my experience its about five minutes.
How this data differs from the reporting api is huge. The data in the reporting API hasn't completed processing for 24 to 48 hours so if you did get info from the reporting api for niw well the data is likely to change after it has been processed.
Real-time data has completed proccesing when it is returned.
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