Google Analytics API: get total events per day/week - google-analytics

For example, I use this query to get the total events in a specific time interval:
https://www.googleapis.com/analytics/v3/data/ga?ids=<redacted>&start-date=2019-01-01&end-date=today&metrics=ga%3AtotalEvents&dimensions=ga%3AeventLabel&filters=ga%3AeventLabel%3D%3D<some value>
How can I get the events per day in that time interval? Is there any other way instead of making a request for each day?

Just to add ga:date dimension in the query to split data by days.

Related

Google Analytics - Get All Events Occurrences With Exact Time

I'm kind of new to google analytics. I have a site where every time a logged user sends a request to the server I'm sending the event to google analytics.
This event contains this fields: {category: 'api_request', action: request url, label: the logged user id'}.
I am wondering if it is possible to see all sent requests for a specific route for a specific user. I will like to get the specific date-time of each request for this route.
I tried to do this in google analytics and found that I can group by action & date, but it doesn't contain the exact time (make sense). Can I achieve this behavior with google analytics or ga-dev-tools?
Be aware of high cardinality
https://support.google.com/analytics/answer/1009671?hl=en
If you start to collect unique data timestamp with every hit, you can soon reach cardinality limit, taht is 50.000 unique dimension values perday. Once you reach this limit, all other collected values will be treated as other.
Consider that day have 86400 seconds.
Date.now()
Date now return time in miliseconds. So every hit will probably have different timestamp and you will reach limit soon.
So if you want to do this, use at least seconds.
Date.now() / 1000;
You have to configure (and send on each event) a custom dimension hit level that contains the current timestamp (i.e. Date.now()).

Multi-Channel Funnels response per day not total

I'm doing this request in Python / Postman:
https://www.googleapis.com/analytics/v3/data/mcf?
ids=ga:xxxx&metrics=
mcf:assistedConversions&
dimensions=&
start-date=2011-10-01&
end-date=2011-10-31
But I only seem to be able to get the total number of results.
1/ Can I get it on a daily granularity? I know that GA API has the ga:date optional parameter, but this does not work in combination with the MCF API and I couldn't find anything similar for MCF.
Do I have to iterate through each day to get the results at a daily granularity?
2/ Is the 30 days lookback applied to API calls? If just put the end date 4 years ahead, will it give me the full results?
Daily granularity: You should add the mcf:nthDay dimension to break the results down into individual days within the specified range:
Index for each day in the specified date range. Index for the first
day (i.e., start-date) in the date range is 0, 1 for the second day,
and so on.
Loopback time: yes it's 30 days and can'be be changed:
Note: The Multi-Channel Funnels Reporting API uses a non-adjustable
30-day lookback window.
If just put the end date 4 years ahead, will it give me the full results?
Why don't you test to find out and let us know :) ?

How to query hourly, daily, monthly using google analytics

I read https://developers.google.com/analytics/devguides/reporting/core/v3/reference
But I did not find how to calculate hourly, daily, monthly statistics.
What query parameter should I specify for it?
Guoping
Here you find the API reference guide for Time Dimensions and Metrics: https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=time
You are looking for:
ga:month
ga:date
ga:hour

Unique Goal Starts

Currently pulling data from the Google Analytics API each day (PHP). The dimensions of this data pull include:
- Date
- Hour
- Minute
Metrics include
- Sessions
- Goalxstarts
- Goalxcompletions (start and completion are for the same goal).
The issue is that when including hour or minute as a dimension, the number of starts appears to include duplicates. For example, if I have 1,000 goalxstarts for a day. When including the hour and minute dimensions in the API call, it might reflect 1,500 goalxstarts.
When running a report in the Google Analytics Web interface (Custom report) with the hour and minute dimension, the goalxstarts metric does not appear to have duplicates.
I should note that goalxcompletions do not duplicate when including the hour and minute dimensions in the API call.
Does anyone know how to retrieve unique goalxstart metrics from the Google Analytics API? Much appreciated...

Google analytics date format

I would like to obtain data via the Google analytics api (Java). Every half an hour once I would be running a script which needs to get me the required variables over the previous half an hour, that is details of the person who has used my site over the last half hour. I do not know if this is possible since the start date and end date parameters can be used only in date format and not in datetime format. How should I proceed with this? Thanks in advance
Google Analytics core reporting API provides 2 dimensions which are the hour and the minute. This should allow you to accomplish what you want, just make sure to wait till the hour and minute you are querying are updated.
Check
https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=time&jump=ga_hour

Resources