Linking Google Analytics event logs to unique session ID - google-analytics

I've been playing with Google Analytics (& tracking events) and I'd like to be able to export my data as a raw log of [session ID, tracking event/analytics statistic] so that I can do my own classification of user sessions. All I seem to be able to do is look at events in aggregate, e.g. event X happened 19 times. Does anyone know if this is possible with Google Analytics? They certainly assign a unique ID, but maybe they choose not to make it possible. If not, positive experiences with MixPanel or others?
(I've seen How do I get raw logs from Google Analytics?, but that was in 2008 before their data export API was public; I'm hoping that I'm missing something.)

Custom variables are the way to go, but still there is the limitation of 50k unique values per month.
Google Analytics uses cookies that have a session ID, so you could read the "__utmb" cookie and use that value as the session identifier.
If you plan on doing deeper identified event/usage tracking, I recommend another tool.

This is one thing that I've never liked about Google Analytics. The workaround is sort of a pain... You basically need a way to identify each unique session, and Google does not provide a way to pull those unique session IDs from their API. Thus, we are forced to create our own...
Add a javascript function that checks the value of a custom variable (one that you are using as a session variable). If the value is empty, you know it's a new session. In this case, assign an incremental value to the custom variable (probably set up an extremely basic table to find get the "next" value). This way you can export whatever data you'd like broken down by session ID.

Related

GoogleAnalytics API: Is there a way to get data by specific session id?

My goal:
I want to save the session ID of Google Analytics (also need to figure out how to get that) with every order on my (PHP based) website & then use that in order to get additional data from GoogleAnalytics about this specific session (for example: duration, device type, browser, ...).
Note: I know how to collect this data by myself, but for other reasons I need to use the data from GoogleAnalytics.
Note2: I have a basic experience with Google's developers console & I managed to build a basic authentication, save the client's token & get general stuff like sessions count. but I need to get deeper & filter specific information.
-- Is that even possible? & if so - how can I do that?
No, not if you mean the session id that GA uses internally, since that is not exposed in the interface or the API. It's generated on the Google server, so you cannot extract the value from the request.
You get a session identifier when you export data to BigQuery but that is only an option if you have a GA360 account (at 120k USD list price that's most likely not an option).
You can create your own session id by creating a session scoped custom dimensions and just send random values with every hit; GA will only store the last value for the session, so that would be a good match for whatever system GA is using internally. You probably want to retrieve the client id an store that in another custom dimension to combine it with your session id.

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: Is it possible to filter the raw data to create more valuable indicators?

We would like to build indicators that provide more useful information than "averages", e.g. instead of having to rely on "average time on page", we would like to create an indicator like "unique users that spent more than [threshold] time on page".
In order to do this, we need to know, whether Google Analytics is storing information on "user session" in connection with "time on page" in its raw data? And if it does, whether this raw data is accessible and can be filtered?
Another situation where the mentioned storing and filtering might come in handy, is the following: if different activities (e.g. post comment, click like, ...) are all tracked with regard to user session, we could build an indicator like: "unique users that performed any of the following: comment, like, ...".
Any reply, remark or comment is highly appreciated.
Raw data is not accessible in Google Analytics.
The closest you will get, if you have a GA360 account, is the BigQuery export, but even that is not "raw" in any meaningful sense (although it is more detailed). You could create a custom sendHitTask to send raw data to your own database.
But raw data would be not useful to you, since GA does not send session data with the raw data. Since 2012/the introduction of Universal Analytics, sessions are entirely calculated on the Google servers - the aforementioned BigQuery export would actually be more useful, since data there is already sessionized, but this requires the paid-for version of GA.
Usually there are workaround for most use cases - i.e. "more than time x" can be viewed as categorical data instead of as metric, so if you send a timestamp in seconds (starting with 0 for the first page view) with each hit to a session scoped custom dimension GA will only retain the last value per session. Then you can filter by all users where that dimension is bigger a given value (you need to use a regex, since you cannot compare dimensions as numbers, and I recommend to create "buckets" instead of having too many discrete values).
But to answer the explicit question, there is no access to raw data (unless you store it yourself) and it would not contain session data in any case.

Google analytics track user behavior. Or possible?

I am searching for a way to track user behavior on my website. I want to know if it is possible to get a table with data looking something like this:
+------+---------------+-----------------+------+---------+
| time | ip or user_id | user_session_id | link | actions |
+------+---------------+-----------------+------+---------+
(Link - where user came from)
I want to track different user actions by sessions. Is this possible using Google Analytics or I should search other tools? My site is currently set up to track events but on my Analytics account I get only the number of events that occurred. I want to track what a specific user does on my site.
tl;dr: if you must do this use Mixpanel or similar software.
Time based dimensions are already available (date, hour, minutes and datetime). "link" would be referrer. Actions in Google Analytics are basically pageviews, events and transactions, so you have that, too.
IP and user id are a big no-gos. Storing anything that that identifies a person is a violation of Googles Terms of Service and depending on your location might be a violation of national laws.And if by user_id you mean the Google Analytics feature of the same name, Google says you may set it for logged in users and have to unset it for user that log out, so by extension that means storing it in Ga would probably be a violation of their TOS.
The GA session id is not exposed via the interface. You may read it from the cookie and store it in a custom dimension (I'm not sure if this is allowed within the TOS, on the other hand GA premium customers get this via a BigQuery export in any case, so it should be allowed).
If you simply want to tell different users apart you might simply generate a string in the UUID format and store that in a custom dimension. If you want to actually identify users (by name, adress etc), well, you are not allowed to and Google will terminate your account if they find out.
Not to mention that it completely eludes why so many people want to track individual users. You must not use GA information to target individuals, and simply looking at individual user paths will not help you (I wrote an article about that, although I do not expect that this will convince you).
Google Analytics is for technical and legal reasons not a good tool for tracking individual users, if you need to do this use a software that is made for this purpose. Mixpanel is often mentioned in that context but I'm sure there are many other solutions.

Google Analytics update a counter based on entries in databse

Is it possible, and if so, how to make a "custom" counter entry in GA, which basically is a count based on database entries.
Quite hard to say without knowing your specific use case, but Google Analytics supports events. You can send custom events to Analytics on every page load. You can then think of a structure with different categories and labels where you can filter these.
If you just want to show the change of the number of entries in a table, you could also think of using a monitoring software like munin. Think about whether your data makes sense together with your other Analytics data or if you just want to show the changes over time together with your other server health parameters.

Resources