microsoft / clarity

A behavioral analytics library that uses dom mutations and user interactions to generate aggregated insights.
https://clarity.microsoft.com
MIT License
2.09k stars 208 forks source link

get session or record id #508

Open vinibgoulart opened 10 months ago

vinibgoulart commented 10 months ago

is there a way to get the session or record id? i want to sync this id with another software i have, but i dont want to generate the id by my side, i would like to get clarity session or record id

rannn505 commented 7 months ago

+1

ranjanamaurya06 commented 1 week ago

Yes, there is an API you can use to get MS Clarity session information, such as user ID, session ID etc. From my experience, this wasn't documented clearly, but after exploring the GitHub repository, I found this method, which works well for my use case. I hope this helps!

window.clarity("metadata", ({ projectId, userId, sessionId }) => {
  // logic goes here
}, false);