Google Analytics API - How to calculate average page depth - google-analytics

I'm trying to determine how to calculate the average page depth for all sessions, daily, for a range of dates. I know that GA has a dimension named ga:pageDepth, but this is not the average page depth. This just returns the number of sessions that had a page depth of 1, and 2, and 3 etc. What I would like is something returned like this:
December 1, 2015: 10
December 2, 2015: 9
Where 10 and 9 represent the average page depth for all sessions.
I've been using the Google Analytics API (Query Explorer) but cannot find a way to do it.

Looks like this would be a good job for a calculated metric - that's a relatively new feature in GA that allows you to create your own metric from existing ones.
Go to your account, admin, view settings, calulacted metric, formatting type "float" and formula "{{Page Views}} / {{Sessions}}" (or whatever, there is an autosuggest feature for all metric names you can use). For use with the API there is an "external name" field (which will default to the name field in the name field with the calcMetric-prefix). In the interface this is available instantly after you created it (so it obviously works on historic data), however I'm not sure it will show up in the query explorer (I created a test metric 10 minutes or so ago and I don't see it in the query explorer. However API use is explicitly mentioned in the docs, so it should be available).
In my accounts this is still marked as "beta" so I'm not sure it's already been rolled out to all GA accounts.

Just use the Pages/Session metric. It's already there....

Related

How is Firebase analytics custom metrics calculated

I'm tracking data associated with an event, for this I put a parameter of programProgress(0 - 1), I created this in the Firebase console as a custom metric.
When I check the console all I see is a graph(attached) of what seems to be the average, no segmentation(like custom dimensions), no explanations. I've gone through multiple documentations and haven't found an answer.
Questions:
Is this graph an average of all data collected, what's the formula?
Is there a way to segment it(preferably in the console) and see amounts for different values i.e. 20 hits for 0.3, 40 for 0.4 etc
Is there a way to segment and see values for different custom dimensions i.e. 30 hits of 0.9 for x dimension(preferably in the console)
Thanks
I believe the easiest way to achieve what you're looking for would be to go into the Google Analytics (GA4) console directly and using the Segment Comparison feature in either the User Explorer or Cohort Explorer techniques.
You can build segments using the programProgress parameter and create multiple for each range you want to specify.

Google Analytics weird User numbers

When I check the website's Users since a certain date it returns a super low value.
The example:
If I want to see the data from 01/01/2016 until 13/06/2021 I get 6 Users, 32.323 New Users, 37.611 Sessions, etc.
The Users number don't make any sense.
However, if I do 01/09/2016 until 13/06/2021 I get 16.849 Users, 16.973 New Users and 22.142 Sessions.
These numbers do make more sense.
So basically, if I consider ANY START DATE before the 01/09/2016 I will always get a super reduced value in the Users part, however, if I consider any start date after, and including, 01/09/2016 I will get reasoable values.
Has anyone ever had this issue?
From 1 September 2016 Google Analytics has brought a new feature, the ability to set the Users metric as the main metric, instead of Sessions. This event has taken the name of Users Everywhere and involves some relationships including Audience Reports and Acquisition Reports.
If the date range includes a period of time, even one day only, prior to 1 September 2016 or around that date, the result is like this:
This is valid, however, if the option to enable the Users metric in the reports , present at the Property level, is active:
Note: Google Analytics Standard properties have aggregated user metrics data since September 1, 2016 while Google Analytics 360 properties started aggregating data from May 1, 2016).
Source: https://www.analyticstraps.com/zero-utenti-con-sessioni/

Download Google Analytics information with a unique user ID

I'm looking to download hit data from a Google Analytics view for a small period of time that includes unique ID for a session and URL that was viewed. I believe I could do this going forward by setting something in Google Tag Manager to a Custom Dimension, but I was looking to avoid that (we have a good number of custom dimensions) and because I wouldn't be able to go backward.
Is it possible in the free version of GA to do something like? I picture the output being the URLs in my x-axis and my users in the y-axix with counts.
I'll be looking to take this data and do a cluster analysis to determine user behavior types.
Nope. Google Analytics does not expose a user specific id via the API or via data exports in a standard account (in GA360 you could use BigQuery to extract the client id).
You either have to set up a custom dimension (as you said this does not work for historic data), or try and use calcuated fields in Google Data Studio in the hope that if you aggregate enough different dimensions into one field you will end up with something specific per user.

Google Analytics list of page views with timestamps?

Is it possible to export a list of all page views, with timestamps, out of google analytics?
Currently I can see page views per day, but not specific times for each view. I do see real-time data as it comes in, so I assume the time for each view is being stored.
If not, how might I go about sending that data when I report the page view in a way that will make it accessible in the dashboard?
[[UPDATE]] The Google Analytics v4 API now includes a "dateHourMinute" dimension.
Inside Google Analytics, I think the problem you will run into is that a "timestamp" includes Date, Hour, Minute, Second (and maybe millisec) and you can only drill into one secondary dimension at a time (ie: just date). An alternative method is to use the query explorer or just use the Google Analytics API.
Ad Hoc Report with query explorer
You can use the Google Analytics API Explorer: https://ga-dev-tools.appspot.com/query-explorer/
It will allow you to select:
A date range
Metrics: (like Users, pageviews, etc)
Dimensions: pagePath, Date, Hour, Minute (can't go to second or further, as in a timestamp, though)
Use filters to get rid of some data.
If your website gets a decent amount of traffic (> 50,000 pageviews per month), you might want to grab it 1 month (or less) at a time to avoid hitting limits/sampling effects.
#doctaj solution works. Please just note that if you are using the query-explorer for example, "dateHourMinute" dimension is considered 3 dimensions and will burn 3 spots from your available 7 or 10 dimensions that you can query. So if you need more dimensions, you need to decide which is more important to you. For example, you may want to query for the date and hour dimensions separately to drop the minutes in favour of something else.

Doing cohort analytics on Google Analytics

Suppose I have 65 people that register on January 1, 2012.
I want to find out how many of those 65 people returned to the site that same week. (More generally, if n people signup on date A, I want to be able to find out how many of those n people return in a given date range.)
Is there a way to do this using Google Analytics? If so, how? I am currently getting the user's username for each page hit.
If you only need to track people who sign in then you don't need to get very fancy. You can copy the relevant user attributes, such as sign up date, from your DB to GA using events or session level custom variables.
But if you want to track everyone, including those who don't sign up, then you'll need to use visitor level custom variables (GA cookies).
I explain how to set this up in detail in this post so I'll just highlight the key points here:
First, decide how to layout the data in Google Analytic's custom variables based on your requirements. For example, are you storing retention dates for daily, weekly or monthly tracking? Do you also want to track cohort goals? Partition this data into the available custom variable slots.
Write the cohort data to these custom variables when visitors arrive or achieve goals using Google Analytic's _setCustomVar function. Setting the fourth parameter of that function to 1 indicates you want to do visitor-level (cookie) tracking.
For each cohort you wish to analyze, create an advanced segment in Google Analytics. Using a regex expression in the condition will give you the flexibility to segment for interesting cohorts. ex: "All users whose first visit was the week before Christmas".
Analyze the results with reports by specifying a date range and the corresponding cohort-sliced advanced segments. Another option is to extract the data using the Google Analytics Data Feed Query Explorer or their API.
Once you've put in the work your new visitors will be stamped by their first visit date and nicely fall into each daily or weekly retention bucket. This is what it might look like if you were tracking weekly retention, for example:
This is not a full solution, but here are some points on how I would approach this problem with the help of Google Analytics:
You have to make sure that you somehow store the registration date of each user, either in your database or in a cookie. Then have a look at Google Analytics Event Tracking. You could for example set up a new category based on the registration date. On every page load in your page, you then have to set up this event tracking call, for example like:
_trackEvent("returns", "2012-01-01", "UserId:123123123")
This way you will receive all page views for users that registered on that particular date. To add a date range in this, you have to make sure that these events only get fired for the number of dates after the signup (e.g. 7 days).
After your date range, you will be able to see how many page views and how many users returned - you even know which users came back.

Resources