# Track Client ID & Session ID?

**URL:** <https://community.piwik.pro/t/track-client-id-session-id/1279>\
**Category:** Data collection and tags\
**Created:** [November 21, 2022, 3:27pm UTC](https://community.piwik.pro/t/track-client-id-session-id/1279 "2022-11-21T15:27:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lasse\_Offt](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lasse_offt/32/942_2.png) [@Lasse\_Offt](https://community.piwik.pro/u/Lasse_Offt)\
**Post date:** [November 21, 2022, 3:27pm UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/1 "2022-11-21T15:27:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [November 21, 2022, 3:34pm UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/2 "2022-11-21T15:34:08Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Lasse\_Offt](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lasse_offt/32/942_2.png) [@Lasse\_Offt](https://community.piwik.pro/u/Lasse_Offt)\
**Post date:** [November 23, 2022, 10:43am UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/3 "2022-11-23T10:43:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rmeekers](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/rmeekers/32/929_2.png) [@rmeekers](https://community.piwik.pro/u/rmeekers)\
**Post date:** [November 23, 2022, 11:01am UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/4 "2022-11-23T11:01:23Z")

</div>

> [@Lasse\_Offt](#):
>
> I want to have the Client ID & Session ID as a custom dimension for our 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](https://help.piwik.pro/support/getting-started/userid/)

> [@Lasse\_Offt](#):
>
> And is this even privacy-friendly?

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

---

<div class="post-metadata">

**Author:** ![joao](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/joao/32/1820_2.png) [@joao](https://community.piwik.pro/u/joao)\
**Post date:** [August 10, 2023, 3:20pm UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/5 "2023-08-10T15:20:11Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [August 10, 2023, 5:20pm UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/7 "2023-08-10T17:20:05Z")

</div>

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

![image](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/2X/0/0e514921cd2dcf476f2e191a77c887a3f390d85e.png)

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](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/2X/c/cf9de23be1cc5b6603ca4271c7b064cded415c92.png)

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

---

<div class="post-metadata">

**Author:** ![joao](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/joao/32/1820_2.png) [@joao](https://community.piwik.pro/u/joao)\
**Post date:** [August 11, 2023, 7:20am UTC](https://community.piwik.pro/t/track-client-id-session-id/1279/8 "2023-08-11T07:20:02Z")

</div>

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. 🙂

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.
