How to update variables for a user after their attribute changes?

In some cases, after a user installs the app, there could be an onboarding flow during which the user may select some options that change their user attributes. If those attributes control the variables the user gets, you may want to update them as soon as this happens. Here's the example flow of events:

1. User installs app
2. Leanplum SDK is started.
3. User goes through onboarding
4. Based on user selection, app sets Leanplum user attributes that control some variables.

In production mode, after Step 4, the attributes will be sent to Leanplum either after backgrounding the app, or after 15 minutes, whichever comes first.

As a result, the variables used on the device will probably not be the correct segmentation at the time those attributes are set.


To make sure users get the latest variables based on their attributes, you can call Leanplum.forceContentUpdate() method after the attributes are set.

This will send them immediately to Leanplum, and also fetch any updated variables, messages and A/B tests.

For more information on syncing mid-session refer to this article:

WARNING: Excessive use of forceContentUpdate() method may result in an increase of userOps, as this overrides the default batching logic and causes additional user operations. Use this method with care.


Was this article helpful?
Have more questions? Submit a request