Google analytics doesn't populate data with particular metric combination - google-analytics

I have multiple analytics accounts, I am facing problem with one of them. I am trying to fetch data through Analytics Core Reporting API v3. The metric combination selected are ga:avgPageLoadTime, ga:users and for other API call I removed the metric ga:users.
For some date ranges I can fetch data when ga:users is added to metric combination, but same API call without ga:users is not fetching any of the data.
metric combination #1:
ga:avgPageLoadTime, ga:users
metric combination #2:
ga:avgPageLoadTime
For some date ranges:
The data gets populated for metric combination #1, but gets no data for metric combination #2. Also with metric combination #2. I am also getting data when filtering is added.
Dimension selected is: ga:deviceCategory

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.

UA Dimensions & Metrics

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:

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