Skip to main content

Hi, we do not pass the IP to Ampliude. How can I still set Country, Region, and City manually? 

I’m looing for a solution either client side (ampli sdk), or by manipulating the request that is sent to the Amplitude product.

Hi Kornelius,

Thank you for contacting Amplitude Support. Happy to help!

You can explicitly define how a user's location properties will be tracked server-side. The HTTP API allows you to send your own [Amplitude] City, [Amplitude] DMA, [Amplitude] Region, and [Amplitude] Country values with your events. You can find example requests here.

I understand that you are looking for a client-side solution. I will reach out to our Engineering team to clarify.

Would you mind letting me know which SDK(s) you are using?

Looking forward to hearing from you!

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.

Thanks for your reply Thao. We are using the ampli browser Codegen.

Hope there is a way to set these values.

 

Best

Kornelius


Hi Kornelius,

Thank you for your prompt response!

I have opened a discussion to clarify with our Engineering team. I will let you know as soon as we have an update.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.
Hi Kornelius,

I have an update from our Engineering team.

1. Country, Region, and City can be set via a Plugin or EventOptions

ampli.myEvent({ ...properties}, { city: 'San Diego', region: ... })


2. User properties are not directly accessible in `track()` calls with Ampli. This is because user properties used to be strongly typed and only settable via `identify`.

That said, in TS, you can send location properties within an event using the Event Classes e.g. `ampli.track(MyEvent())`, instead of Event methods e.g. `ampli.myEvent()`

import {ampli, MyEvent} from './ampli'val ampliEvent = MyEvent(...strongTypes)ampliEvent.user_properties = { ...userProps }ampli.track(ampliEvent)

More Ampli docs here - Ampli

I hope this helps. Please don't hesitate to let me know if you have any questions.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.
Hi Kornelius,

You are welcome!

If you set `location_lat` and `location_lng` outside the user and event property brackets (see example below), Amplitude will use these values to determine location properties only if IP address is unavailable.

But if these values are sent as event properties, they won't be used to detect location. In this case, location properties will be determined by the IP address.


'events': [{'user_id': 'test_user','event_type': 'test_event','location_lat': 37.774929,'location_lng': -122.419418}


I hope this helps. Please don't hesitate to let me know if you have any questions.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.
Hi Kornelius,

Thank you for your follow-up question. Happy to assist!

1. Amplitude automatically tracks IP address values for data sent via our SDKs. The IP address value is determined from the request/end user. So the IP address value will be what was collected from the user's event, provided they have location tracking enabled on their device.

As for data sent via server-side (i.e via our APIs), customers set IP address values in the API requests.

2. If you're looking to exclude the IP address from your events, you can do so by configuring your SDK (see example here).

Alternatively, we can block IP addresses from our backend. When you block IP addresses for a specific project, IP addresses don't show up in UI, but we still ingest it and use it for reverse geo lookup. Then, we just scrub the value off afterward. I'd like to note that the change only applies to future events. Historical events will still include the IP addresses.

If you'd like to block IP addresses, please feel free to send me your project IDs and I'll make the change on our backend.

I hope this answers your question. Let me know if you need further clarification.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.

Reply