Solved

How to get device-related data on the client and send it to the server

  • 21 June 2023
  • 1 reply
  • 331 views

Hey guys,

 

I'm working on integrating Amplitude into my application, which is a platform built using ReactJS for the frontend and Node.js for the backend. I am currently using the "@amplitude/analytics-browser" library (~1.10.3) on the frontend and "@amplitude/analytics-node" library (^1.1.7) on the backend.

My current implementation is configured to make an API request from the frontend to the backend, sending information that will be useful to generate an event on the backend (sessionId, userId, deviceId, user properties and event properties). Then, the backend uses this information to log an event to Amplitude.

What I'm trying to achieve now is to include more user properties, specifically device related data such as device type, device family, platform, and operating system. I am aware that the Amplitude JavaScript SDK can automatically fetch this data from the user agent string on the client side, but I can't seem to find a way to access this data and send it to the backend.

I am wondering if there is a built in solution to get this device related data on the client and send it to the server. I understand the limitations of not having direct access to the User Agent string on the server side, but any ideas or recommendations on how I might get this information would be greatly appreciated.

 

Thank you in advance for your help.

icon

Best answer by Saish Redkar 21 June 2023, 19:54

View original

1 reply

Userlevel 7
Badge +10

Hi @kelvin jose hernandez cabrera
Are you sending events from client side ( via browser SDK ) and capturing the available default Amplitude user properties values? 

From the above link you can see that Amplitude is able to capture some key device info like device type, os,etc ( but not browser info by default) using the client SDKs.

But if you are ONLY sending events server-side ( using node sdk ), then you must instead set those properties explicitly. 

If you are already setting the device related info using the default Amplitude properties via browser sdk, then these properties will be applied to all events from that user until their values are changed.

So even if you aren’t able to capture these explicitly and send via backend events, the previous values will be applied to all the events.

Let me know if I understood your use case here.

 

 

Reply