Skip to main content

Hello, I’m trying to specify the platform field when triggering a logEvent, but thanks to the post below I found out that for the JS SDK the “platform” field always stays as “Web”, so, is there a way to manually change this?
I tried using something like:
amplitude.options.platform = “Android”
Before logging the event, but that didn’t work.

 

Hey @roy.gf 

The default platform value for the JS SDK will be “Web”

I haven’t tried this myself, but you can try defining your custom value for that field by initializing the instance with ‘options’ as seen here -

https://www.docs.developers.amplitude.com/data/sdks/javascript/#initialization-with-options ( Legacy JS SDK)

You can refer to the available options in here https://github.com/amplitude/Amplitude-JavaScript/blob/main/src/options.js

Also curious to know if there is any specific use case for trying to rename the default “Web” to “Android” while using the JS SDK?


Thank you @Saish Redkar ! I have tried that but it didn’t seem to work, the platform field just keeps as “Web”.

Also curious to know if there is any specific use case for trying to rename the default “Web” to “Android” while using the JS SDK?

Right so I’m working on a Rails web app that also has an iOS and Android version, but these apps are using Chrome/Safari webviews to render the app, and that’s why I would like to pass it something like “Mobile” instead of Web (when it’s being triggered from one of the mobile webviews). Do you think that there is an alternative for this? Something like using User groups to create a “device_platform” field and assign to it either “mobile” or “web” values?


Hi @roy.gf ! I would recommend setting up your own custom user property to reflect the platform values you are looking for so a custom user property something like what you suggested “device_platform” would probably be best. 


Hello @belinda.chiu  Please i am currently having issues with setting this Platform field.
I am experiencing a similar issue as other people have narrated here, but i want to be able to update this property without creating a new one. 
Also i use segment sdk and have setup amplitude as a source, do you know or can you point me to where i can update this property using the segment analytics javascript sdk.

Thank you.


Hi @allindeveloper ! Welcome to the Amplitude Community and happy to help 🙂 As mentioned above, the Amplitude Platform property cannot be changed if you are using our JS SDK. It will always say “Web”. If you want to have a different Platform value, you will need to create your own custom property. 

Here’s a Community Post that made a while back that surfaces which default value will be prepopulated depending on what SDK you use. If you are using server-side APIs or integrations, then you are more than welcome to input any value you wish. 

 


Reply