To run Application Insights without referring to cookies, you can use the disableCookiesUsage
configuration option which is available in the [javascript SDK]. When this option is set to true
, the SDK won't store or read any data from cookies, and the User and Session cookies will be disabled. You can also use the isStorageUseDisabled
configuration option to disable the SDK from storing or reading any data from local and session storage.
EDIT 2023 Apr 6: To track specific users, overwrite the user_Id
field when the user starts a new session. By default, Application Insights randomly generates this value, see Managing personal data in Log Analytics and Application Insights.
TelemetryClient telemetryClient = new TelemetryClient();
telemetryClient.Context.User.Id = "unique_user_id";
Once you've set the user_id
, you can query for the session in Application Insights, for example counting the number of user sessions in the last 24 hours.
requests
| where timestamp > ago(1d)
| summarize numSessions_24h = dcount(user_Id) by user_Id