google analytics product data with demographic dimension - google-analytics

Currently i have an ecommerce site being tracked by google analytics, implemented with gtag.js.
here's what i was trying to do :
get product-related data form enhanced ecommerce reports with demographic dimensions in Reporting API
e.g.
request metrics : product detailed view, product checkouts, product added to carts, item quantity, purchased value
along with following dimension : product sku + gender + age + device + browser
here's what i've done so far :
enable [ Enable Demographics and Interest Reports ] in [ Property Settings ], in Google Analytics GUI
enable [ Enable Enhanced Ecommerce Reporting ] in [ View Settings ], in Google Analytics GUI
enable [ Enable Ecommerce ] in [ View Settings ], in Google Analytics GUI
test whether current request is fine with the dimension & metric explorer ( link ) -> think it is a valid combination
results i'm getting so far :
can get ecommerce data with the following combination of dimensions : ( browser + gender + age + device + time )
cannot get ecommerce data with the following combination of dimensions : ( sku + browser + gender + age + device + time )
i don't think adding a ga('require', 'displayfeatures'); code would help, since i implemented by using gtag.js...
( related link : https://support.google.com/analytics/answer/2444872?authuser=1 )
and ideas? or points to give?

According with Dimensions & Metrics Explorer (https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/) this combination of dimensions is questionable: sku + browser + gender + age + device + time.
However, when analyzing users based on age, gender and interest categories it should be taken into account that this data, in Google Analytics, is only available to a subset of users (https://www.analyticstraps.com/i-report-con-i-dati-demografici-non-tornano/).
Also, the documentation About Demographics and Interests says:
Thresholds are applied to prevent anyone viewing a report from inferring the demographics or interests of individual users. When a report contains Age, Gender, or Interest Category (as a primary or secondary dimension, or as part of an applied segment), a threshold may be applied and some data may be withheld from the report. For example, if there are fewer than N instances of Gender=male in a report, then data for the male value may be withheld.
These thresholds are system defined, and you cannot adjust them.
If a threshold has been applied to a report, you will see a notice below the report title.
For this reason, when you use one of the demographic reports as a dimension, the data is no longer complete.

Related

Google Analytics Data API (GA4) in R - Google Ads clicks

I use R Studio to export the necessary data from the GA4 property. I wanted to collect data on Google Ads campaign name, number of sessions and Google Ads clicks assigned to the corresponding campaigns. The number of sessions downloads to me, but it shows 0 Google Ads clicks, although I can see in the GA4 property that the clicks are there. Have you also had this problem? I am using the publisherAdclicks metric:
metric in R Studio API
I have not found any other metric through which I can retrieve this data, so do you have any idea what the problem is?
My code looks like this:
googleAdsSessionsClick <- google_analytics_set(c("sessions", "publisherAdClicks"),
c("sessionCampaignName", "sessionSourceMedium"))
I use my own function:
google_analytics_set <- function(choosenMetrics = NULL, choosenDimentions = NULL) {ga_data(webPropertyId,
date_range = date,
metrics = choosenMetrics,
dimensions = choosenDimentions)}

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 - 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 - How to filter by page, group by query string value?

I have a site with a store search that posts in the following format.
www.site.com/store-locator?city=&province=&zip[postal_code]=68123
I am trying to configure GA to give me feedback on people visiting this page and a count of specific zips searched.
example report data
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
/store-locator?city=&province=&zip[postal_code]=68456 768 visits
/store-locator?city=&province=&zip[postal_code]=68789 221 visits
note: the 'city' and 'province' values may also be populated (and I will want to mod GA to give similar data on these too).
Can anyone give feedback on how to configure GA to give me data similar to this?
Thanks!
As far as I know, the only way to look at this type of segment historically is using individual segments, which doesn't work well for an arbitrary number of zip codes. However, you can collect this data more effectively as described for new traffic. This comes up often with information like categories, tags, dates, query string variables, etc.
You can create Segments for each zip. This will work for historical analysis, but is impractical beyond a few. https://support.google.com/analytics/answer/3124493?hl=en&ref_topic=3123779
You can also use Content Grouping to create groups. This will not work historically. https://support.google.com/analytics/answer/2853423
The way I've handled this is using Custom Dimensions, which replaced Custom Variables when Universal came out. This also only works for future data.
To use Custom Dimensions, you would pass the zip code to google analytics explicitly when calling the analytics javascript code.
You can pull querystrings with javascript, or echo the parameter using something like PHP as follows:
<?php
if (array_key_exists("zip",$_GET)) { $theZip = $_GET["zip"]; }
else { $theZip = "nozip"; }
?>
And, sending the custom dimension --
ga('create', 'UA-XXXXX');
ga('set', {'dimension1': '<?php echo $theZip; ?>'})
ga('send', 'pageview');
You also need to setup the custom dimension in the Analytics Profile. Docs on custom dimensions https://developers.google.com/analytics/devguides/platform/customdimsmets
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
Step 1: In GTM, create a new macro. I called mine {{province}}
Macto Type = URL
Component Type = Query
Query Key = province
This will populate the Macro with the value of province from the query string.
Step 2: In your Google Analytics property, define a custom dimension called "province". This will assign an index key to the dimension.
Step 3: In your GTM tag for Google Analytics, you will find Custom Dimensions under more settings. Add a new dimension, apply the index number from #2 and for the dimension select the macro you created from #1
Publish and you are all set.
Now when you look in Google Analytics, you can add a secondary dimension and choose your newly created custom dimension.

How to count (unique) custom values for a metric in Google Analytics?

Trying to figure out "how many users logged-in last month?" on my website using Google Analytics' web-interface (or API).
For each request, I'm sending user id's in a custom variable as the value:
_gaq.push(['_setCustomVar', 2, 'user_id', '#{ current_user ? current_user.id : 0 }']);
How can I get the number of unique user id's for all pageviews within a certain time-range?
Create a custom segment[*] that includes only visitors with your custom var set. Apply the segment and the audience overview tab will display your desired numbers.
[*] Advanced segments->create custom segment -> first dropdown to "include", second to "Custom Variable 2", third "Exactly matching" and the textfield gets the value for logged-in visitors
Sadly not possible in Google Analytics.
But you can do this in Google Data Studio. There you can create Dashboards for Google Analytics and create a new calculated field, like: COUNT(User ID)

Resources