Solved

I would like to replace amplitude default fields using Legacy JS SDK

  • 17 November 2022
  • 6 replies
  • 30 views

Badge

Dear all,

I’m using the JS SDK to log events for interactions on my web application. I would like to replace selected fields that are automatically determined by the amplitude instance, for e.g. ip address, country, city, etc.

Is this possible? I’ve tried to use identify or setUserProperties

const identify = new amplitude.Identify().set('ip', '111.111.111.111');
amplitude.getInstance().identify(identify)

// or

amplitude.getInstance().setUserProperties({ 'ip': '111.111.111.111' });

but these will create a custom property instead. 

Is there a way for me to replace the amplitude fields? (mainly the ip address detected by the amplitude instance) I’ve attached an image below indicating the value of the `IP Address` field that i’d like to change. 

 

 

Note: I’d like to avoid creating a custom user property or event property for this ip address.

Thank you in advance for your help!

icon

Best answer by dangrainger 17 November 2022, 07:42

View original

6 replies

Badge +1

Hey @as-greywing !

Thought occurs…is there a genuine need to overwrite the defaults rather than just having a custom user property for each?

Even if possible to do the overwrite, it’s not something I personally would advise in any analytics tool, whether Amplitude, GA, Adobe or otherwise…typically these out of the box default fields (particularly the location ones) are intrinsically wired into various functionalities elsewhere in the tools or the wider product stack from a given vendor, hence me saying I’d leave them alone. In your case I’d run with ip_custom, city_custom, etc.

Dan.

Badge

Hey @as-greywing !

Thought occurs…is there a genuine need to overwrite the defaults rather than just having a custom user property for each?

Even if possible to do the overwrite, it’s not something I personally would advise in any analytics tool, whether Amplitude, GA, Adobe or otherwise…typically these out of the box default fields (particularly the location ones) are intrinsically wired into various functionalities elsewhere in the tools or the wider product stack from a given vendor, hence me saying I’d leave them alone. In your case I’d run with ip_custom, city_custom, etc.

Dan.

Hi Dan,

Thanks for your feedback. We’re exploring that option as we’re thinking that in some cases we can get better location stats, and would like to replace the existing values; during the analysis stage, when someone else run reports on the collected data, there won’t be any additional filtering changes required (or educating the analyst of this new property).

Kind regards,

Albert

Badge +1

P.S. Take a look at this page, you’ll see a section on how to disable the default properties…

https://www.docs.developers.amplitude.com/data/sdks/javascript/#disable-tracking

I’ve not tried this, but I’d guess “ip_address” in this reference is the one you’re looking to change the value of. As I said though, personally I’d be strongly questioning the need to do it at all given possible risk to functionality, and instead go down the custom route.

 

Badge

P.S. Take a look at this page, you’ll see a section on how to disable the default properties…

https://www.docs.developers.amplitude.com/data/sdks/javascript/#disable-tracking

I’ve not tried this, but I’d guess “ip_address” in this reference is the one you’re looking to change the value of. As I said though, personally I’d be strongly questioning the need to do it at all given possible risk to functionality, and instead go down the custom route.

 

Yep i’ve tried that. After disabling, it just stopped recording, but any attempts at saving `ip_address`, `ip`, `ipAddress`, etc doesn’t go through within the default field.

Noted on your suggestion to stick with custom :) 

I wanted to see if the amplitude team had a way for this since, the httpv2 API seems to allow us to provide those values according to the docs (note: i haven’t tried this method)

https://www.docs.developers.amplitude.com/analytics/apis/http-v2-api/#device-ids-and-user-ids-minimum-length

Kind regards,

Albert

Userlevel 6
Badge +8

Hi @as-greywing ,

 

I would agree with @dangrainger ‘s excellent breakdown here, it is not something that we can advise . Unfortunately, we do not have the functionality to change the value of the IP Address and other Amplitude fields, these are determined by the SDK. Unless you were to send in an HTTP API 2 event, like you said, with the specific values in the payload. The SDK can disable tracking for certain fields but it does not allow you to input custom values for those fields. 

I would try to implement a custom user property to track a different IP Address if you needed to. I hope that helps!

 

Kind Regards,
Denis

Badge

Noted on the above and thank you for the response @Denis Holmes

 

Reply