User_Id how to?

We have inserted code for User_id, but it is not generating anything.

Do you see the userid in the visitor log?

Here are some examples of userid in log @Lukas

Hi,

Sorry that my message was a bit ambiguous. I meant that you check if in the visitor log (https://demo.matomo.org/index.php?module=CoreHome&action=index&idSite=62&period=day&date=yesterday#?idSite=62&period=day&date=yesterday&segment=&category=General_Visitors&subcategory=Live_VisitorLog) you can see visits appearing that have the user id set.

@Lukas It does not show User Id in visitor log.

In that case I’d recommend to temporarily enable https://developer.matomo.org/api-reference/tracking-api#debugging-the-tracker which makes the matomo.php respond with a verbose log on which parameters where recieved and stored.

@Lukas It is already on, but is not sure how to debug! are there any links/forum answers on it?

Just check the output you recieve from the HTTP request and see if there are any messages regarding user id or the uid parameter.

Sorry to bother you @Lukas but I have no clue what so ever on how to do that!

If I understand the first post correctly, you wrote some C# code that makes a request to the Matomo tracking API.
But now that I take a closer look at it, I notice something weird: You aren’t sending any actual tracking data there, which means you probably send one request with the tracking data and then one with the &uid=theuser.
For Matomo to properly detect a user, you need to add the uid= part to the actual tracking request where you send the data like action_name instead of doing it in a separate request so that Matomo knows that this user is doing this action.

So does that mean that we have to send ‘action_name’ with request? Are there any sample request in documentation? @Lukas

You are already sending action_name with the request otherwise the data would not show up in Matomo. Are you using some SDK to send the tracking requests to send the tracking data in C#?

Or am I completely misunderstanding you and you are not sending the tracking data server side in your C# code, but are using the normal Javascript tracking script?

In which case you don’t need to make any requests server side, but instead set the UserID in Javascript by adding this to the tracking script
https://developer.matomo.org/guides/tracking-javascript-guide#user-id

_paq.push(['setUserId', 'USER_ID_HERE']);

or modify the code that generates your HTML so that it places the userID there.

@Lukas
From my Developer :
We are using c# with rest api and Not any sdk
Please send us sample request, as to what to put in tracking data
We are already setting up user id

In which case instead of doing the additional request in SetMatomoUserId, modify the code where you send the other tracking data to Matomo and add the uid parameter there.

@Lukas
Sorry, my developer is not clear when you cay ’ tracking data to Matomo and add the uid parameter there’ as we are not using any other matomo api or tracking data, we just want to see users who logged in.

Is it possible for you to send us a sample request, please?

thank you

A “normal” request to matomo.php might look something like this.
POST https://demo.matomo.org/matomo.php?action_name=Matomo Analytics - The Google Analytics alternative that protects your data&idsite=1&rec=1&r=213385&h=12&m=55&s=33&url=https://matomo.org/&_id=94b1e16cbf3a32de&_idts=1568638341&_idvc=0&_idn=0&_refts=1595585079&_viewts=&_ref=https://duckduckgo.com/&send_image=0&cookie=1&res=2560x1080&_cvar={"1":["Domain landed","matomo.org"]}&gt_ms=53&pv_id=E68OvW

You already have code that makes this request (otherwise how would data get into your Matomo instance?), you just need to modfiy it.

@Lukas
do you mean we add user id to the above code or add this to api call?