SuprSend identifies users with immutable distinct_id. It’s best to map the same identifier in your DB with distinct_id in SuprSend. Do not use identifiers that can be changed like email or phone number. You can view synced users by searching distinct_id on Users page.
To create a new user or to update an existing user, you’ll have to fetch user instance. Call supr_client.user.get_instance to instantiate user object.
Copy
Ask AI
user := suprClient.Users.GetInstance("_distinct_id_") // Unique identifier of user in your application// Save user_, err = user.Save()if err != nil { log.Fatalln(err)}
To Edit user, you need to first fetch user instance, call all the update methods and save changes using users.Save() method.
Copy
Ask AI
func main() { // Fetch user instance user := suprClient.Users.GetEditInstance("_distinct_id_") // Call user update methods user.SetTimezone("America/Los_Angeles") user.Set("name", "John Doe") // Save Changes res, err := user.Save() if err != nil { log.Fatalln(err) } fmt.Println(res)}
Here’s a list of all edit methods:
Add User Channels
Add communication channels on which you want to notify user. Push sand Inbox tokens are automatically tracked on user identification when the corresponding frontend SDK is integrated. Other channels (Email, SMS, Slack, MS teams, Whatsapp) need to be explicitly set in user profile.Use user.Add* method(s) to add user channels.
This method will delete/unset all values in specified channel for user (ex: remove all emails attached to user).
Copy
Ask AI
// If you need to remove all emails for this user, call user.Unset(["$email"])user.Unset([]string{"$email"})// Supported channel keys are:// $email, $whatsapp, $sms, $androidpush, $iospush, $webpush, $slack, $ms_teams
Set Preferred language
If you want to send notification in user’s preferred language, you can set it by passing language code in this method. This is useful especially for the applications which offer vernacular or multi-lingual support.
Copy
Ask AI
// Set user preferred language. languageCode must be in [ISO 639-1 2-letter] formatuser.SetPreferredLanguage("en")
Set preferred timezone
You can set timezone of user using this method. Value for timezone must be from amongst the IANA timezones.
Copy
Ask AI
user.SetTimezone("America/Los_Angeles")
Set
Set is used to add custom user properties. It is an upsert function, meaning any existing property value with the same key will be overwritten on subsequent updates.
After calling Add/Remove/Unset methods, don’t forget to call user.Save() since user edit is async update and the changes will be sent to SuprSend only after calling this method.
There isn’t any limit on number-of-records that can be added to bulk_users instance.Use .Append() on bulk_users instance to add however-many-records to call in bulk.