UA Dimensions & Metrics - google-analytics

I am using the GA4 (Google.Apis.AnalyticsReporting.v4) reporting API to create a dashboard for my company.
I noticed that if you select the following dimension:-
TIME/ga:dateHourMinute,
ADWORDS/ga:adwordsCampaignID
ADWORDS/ga:adwordsAdGroupID
with METRICS:-
ga:impressions,
ga:CPC
ga:adCost no data is returned
BUT if you change the selection to dimensions:-
TIME/ga:date,
ADWORDS/ga:adwordsCampaignID,
ADWORDS/ga:adwordsAdGroupID
with METRICS:-
ga:impressions,
ga:CPC
ga:adCost
data is returned. Does anyone know how to get the first query to return data?

The dimension ga:dateHourMinute is not compatible with the metrics ga:impressions, ga:CPC, and ga:adCost. Google Analytics does not store these metrics broken down by date, hour, and minute. If you send the first query, you will get that the dimensions and metrics are incompatible:
You can visit the dimension & metric explorer to plan a query for compatible dimensions and metrics. If you check the fields ga:adwordsCampaignID, ga:adwordsAdGroupID, ga:impressions, ga:CPC, and ga:adCost, then the dimension ga:dateHourMinute is grayed out to signify incompatibility:

Related

Google Analytics 4 - How to Get Event Data via GA4 Reporting API

Previously, with Universal Analytics, it was possible to request goal data via API by specifying the goal number, for example:
ga:goal01Completions
In GA4, assuming the event has been 'marked as conversion', this can be replicated by specifying the conversion name, for example:
conversions:online_enquiry
However is there are generalised method in GA4 which can request the count of any named event, regardless of whether or not it has been marked as a conversion, for example:
events:online_enquiry
events:page_view
events:begin_checkout
events:scroll
events:404_not_found
I used the runReport before.
https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
It's creating a report. Dimension is eventName and Metric might be eventCount or other you prefer.
Here is the list dimension and metric you can find
Metric
Dimension
But still open to better way maybe I don't know.

What is the expected Azure Time-Series-Insights Gen2 API-behavior incase of take-parameter is used for GetEvents and GetSeries endpoints?

I am currently experimenting with the Azure TSI Gen2 ApiVersion = "2020-07-31" and I am wondering the effect of the GetSeries and GetEvents endpoints Take-parameter.
If I query TSI data for a wide searchSpan that contains more events than I define on my Take-parameter, what happens? Is the data returned in some order? What is the expected form of the response data?
Documentation definition for the Take
take - integer - Maximum number of property values in the whole response
set, not the maximum number of property values per page. Defaults to
10,000 when not set. Maximum value of take can be 250,000.
The take parameter specifies the number of events returned by the query (across pages). So if your search span has more events than your "take", TSI randomly selects, or 'takes', that set of records from storage. E.g. if you have 20k events in your search span, and a take of 10k, you'd get a random 10k events from the 20k in that timeframe.
In the TSI explorer, when you "Explore Events" to see the raw data, the explorer calls GetEvents. TSI explorer will always try to show the max (250k) events and will notify you if there more than 250k in the search span.
Data isn't returned in any order by the APIs. Adding sorting capabilities is something we have on our roadmap. Here's a feedback item where you can upvote the request to add this functionality, as well.
Here's some examples showing the request/response of GetEvents and other APIs.
As documented here: https://learn.microsoft.com/en-us/azure/time-series-insights/concepts-query-overview#time-series-query-tsq-apis
Get Events and Get Series API supports pagination to retrieve the complete response dataset for the selected input.

Google analytics API: different sum of sessions with 'ga:eventLabel' function and without it

I added 'ga:eventLabel' function to my script and sum of sessions decreased from 2238 to 994. Why?
I expect the same result from both script
dim=['ga:eventLabel', 'ga:source','ga:sourceMedium']
met=['ga:sessions', 'ga:users']
start_date='2019-07-01'
end_date='2019-07-03'
transaction_type='Goal'
goal_number=''
refresh_token=token
condition=''
data_2=google_analytics_reporting_api_data_extraction(viewID,dim,met,start_date,end_date,refresh_token,transaction_type,goal_number,condition)
viewID='*********'
dim=['ga:source','ga:sourceMedium']
met=['ga:sessions', 'ga:users']
start_date='2019-07-01'
end_date='2019-07-03'
transaction_type='Goal'
goal_number=''
refresh_token=token
condition=''
data=google_analytics_reporting_api_data_extraction(viewID,dim,met,start_date,end_date, refresh_token,transaction_type, goal_number,condition)```
Here are the results:
--
The two queries have two different meanings, and won't give you the same result, unless you have a data set, where all sessions have at least one event type hit associated with them.
The first query says: count all my users and sessions for the given date range, breaking it down by event label, source, source/medium and date. So in this case, you implicitly filter for any known event labels, where (not set) is an empty, but existing label for a recorded event. Sessions without any events are excluded.
The second query says: count all my users and sessions for the given date range, breaking it down by source, source/medium and date (regardless, if they had any events).
You can verify this behavior, if you create these custom reports in Google Analytics web UI. It is similar to querying custom dimensions: if no value was set for a given custom dimension, those records are excluded.

Google analytics - metrics mismatch while exporting data via API with various set of dimensions

I am working on GA reporting metrics in Power BI via reporting API.
While I create a query with some very basic attributes like sessions and users, I get same values as I can see directly in google analytics dashboard.
but when I add more dimensions and attributes, say, user type, pageviews or gender etc, alingwith users and sessions, the value of users and sessions is inflated.
I have tried to go through various documentations, where I know there are some restrictions that not all dimensions and attributes can be put together, but in this case, GA has allowed me to add these basic attributes togehter but the results are not matching.
Is there any documentation to explain this behaviur, or has anyone experienced anything like this.
has this to do something to do with binning, though I would expect, even if the difference is due to different binnings on different counters, the difference should be a smaller value, not the ones I am getting, which is huge(multiple times of error ) not just few percent of error.
I have come across with this problem and the reason is because of a limit on Google Analytics Core Reporting API.
Sampling thresholds
Default reports are not subject to sampling.
Ad-hoc queries of your data are subject to the following general
thresholds for sampling:
Analytics Standard: 500k sessions at the property level for the date
range you are using
Analytics 360: 100M sessions at the view level for
the date range you are using
i.e. Once the data you are requesting is returning more than 500k sessions / rows of data in a query, Google Analytics will return sampling data but not exact data.
The way I work around with this limit is to break down the query into separate queries (to make sure the returned data is fewer than 500k rows) with a date filter (per year, month or day, depends on data volume) apply to each of it. Then append all the queries back into one.
Sample M code:
(year as number, month as number) =>
let
Source = GoogleAnalytics.Accounts(),
...,
#"Added Items" = Cube.Transform(#"...", {{Cube.AddAndExpandDimensionColumn, "ga:pagePath", {"ga:pagePath"}, {"Page"}}, {Cube.AddAndExpandDimensionColumn, "ga:pageDepth", {"ga:pageDepth"}, {"Page Depth"}}, {Cube.AddAndExpandDimensionColumn, "ga:pageTitle", {"ga:pageTitle"}, {"Page Title"}}, {Cube.AddAndExpandDimensionColumn, "ga:date", {"ga:date"}, {"Date"}}, {Cube.AddMeasureColumn, "Page Load Time (ms)", "ga:pageLoadTime"}}),
#"Filtered Rows" = Table.SelectRows(#"Added Items", each [Date] >= #date(year, month, 1) and [Date] <= Date.EndOfMonth(#date(year, month, 1)))
in
#"Filtered Rows"
Result:

Google Analytics API does not return traffic per dimension (e.g. country/browser)

When I query Google Analytics for traffic (ga:visits,ga:pageviews) filtered by ga:userDefinesValue with no dimension specified, within a time period (e.g. 2012-08-01 to 2012-09-01), I get a result:
Your query matched 1 results and the API only returned the following 1 results:
ga:visits  ga:pageviews 
7 21
The problem is that when I add any dimension to the query (e.g. ga:country or ga:pagePath) i get an empty results set:
(none) 
no results found
What could be the reason for this behavior?
Thanks.
From your description you state you are using country and pagePath as a metric, this will fail as they are dimensions.
Add ga:country as a dimension and the report should work.

Resources