How do I set `user_properties` on identify calls with ampli?

  • 10 March 2023
  • 3 replies

How do I set `user_properties` on identify calls with ampli?

This page here say that the ampli will generate an identify method with an overload that looks like:

ampli.identify('user_id', {/* user props */}, {/* amplitude options */ })

but that isn’t what I see with `@amplitude/ampli/1.31.0 darwin-arm64 node-v18.14.1` /      `@amplitude/analytics-browser@1.9.1`

* Identify a user and set user properties.
* @param userId The user's id.
* @param options Optional event options.
userId: string | undefined,
options?: EventOptions,
): PromiseResult<Result> {
if (!this.isInitializedAndEnabled()) {
return getVoidPromiseResult();

if (userId) {
options = {...options, user_id: userId};

const amplitudeIdentify = new amplitude.Identify();
return this.amplitude!.identify(

type `EventOptions` looks promising, especially the `.extra` field -- but when passing values into that field, do not see them in the user_properties event of the outgoing identify requests.


I can and will drop down to the untyped SDK, but how am I supposed to do this with the ampli wrapper?


Best answer by PatrickGravity 27 March 2023, 16:48

View original

3 replies

The empty user_properties even is created here in the event-builder:

At that point, the eventOptions are dropped.  It seems like the Ampli SDK is failing to set any of the event properties except for the userId and device id on the Identify class instance, and the event-builder expects them to be on the Identify instance not the eventOptions (it just runs Identify.get)

So you’d expect this addition to the generated code to fix it:


And it does:


This is starting to feel like a “your problem” thing.

Userlevel 6
Badge +9

Hi @PatrickGravity, please excuse the delay here. Somehow we missed your reply. Were you able to make progress here?

I was able to get help in another channel.

The issue is that user properties are also strongly typed by Ampli, so I needed the product team to add this to the tracking plan on amplitude, not just ask me to provide the property.  Once that happened, Ampli generated the necessary code to handle the new properties.