Track Client ID & Session ID?

Hey there!

I want to have the Client ID & Session ID as a custom dimension for our analysis. I know there are these two Cookies: “_pk_id” & “_pk_ses”. So it worked that i read out the Value of the “_pk_id” cookie. But for the “_pk_ses” cookie its always a “*”, so probably this isn’t working this way.
Does someone has a best Practise for this? And is this even privacy-friendly?

Thank you in advance
Lasse Offt

What do you mean by Session ID here? _pk_id stores personal data (cookie id), so it’s fine to store it only when there’s valid consent. Not sure though why you want it to be stored as a custom dimension when it’s available as a built-in one (Visitor ID).

Yes true that would be obsolete, with the _pk_id Cookie. With the Session ID, i mean the ID wich is assigned to every Session by a User. We want to have this information in a dimension to segment this by the Sessions in the analysis.

Is there a reason why you wouldn’t use the built-in User ID functionality? See Set up a user ID | Piwik PRO help center

Under GDPR you may only track PII when the visitor gave consent.

@kuba Having a unique Session ID for each session would allow us to create a “session table”, where each row in the table is a unique session.

This can then be used to count the number of sessions with a specific event, e.g. number of sessions with one or more add to carts, number of sessions with one or more menu clicks, etc.

I have tried to concatenate the Visitor ID with the Session number to create this unique session identifier, but it seems that this is not unique: the built-in Sessions metric sometimes is greater than 1 for a given “Visitor ID/Session number” string.

Hi. You can achieve the same thing by using adds to cart metric:

image

You can use it to just display the raw numbers, for which you can use the sessions metric, or you can also transform it to see things like median or avg.

Same goes for different event types - you can get the total number and uniques pretty easily.

As for getting the number of sessions in which particular event was triggered, you can do it the other way round:

image

And then filter it to show data only for certain event types.

1 Like

Hi @kuba thank you for pointing me in right direction. Nothing like a good night’s sleep to get a fresh perspective on a problem, I was indeed overcomplicating it. :slight_smile:

Indeed, I can use a combination of Unique custom events in session, and filter on a specific event’s category and action values to get what I need, thank you.