Pini
Pini

Reputation: 439

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?

Upvotes: 0

Views: 2971

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

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.

Upvotes: 3

Related Questions