Identifying Users

This guide describes how PurchaseStacks handle user identity

To us, the Apple ID or Google ID is the source of truth for the user identity. When initializing the SDK, we create an anonymouser user with a random App User ID provided by our system.

With PurchaseStacks SDK, you have the option to track the user with your own user ID later or when initializing. You can use the App User ID generated by us, if you do not have any backend system. You can search with the App User ID or External User ID/Email provided by you in the dashboard to find our his purchases.

info

Setting your own App User ID will allow you to reference users in the PurchaseStacks dashboard, via the API, as well as in the webhooks and other integrations.

Anonymous App User ID

If you don't provide an App User ID when instantiating the SDK, PurchaseStacks will create a new random App User ID for you. In the event that the user deletes and reinstalls the app, a new random App User ID will be generated.

PSPurchase.config(withAPIKey: "API_KEY", withAPISecret: "API_SECRET")

Set App User ID on configuration

tip

If you have user info, it's recommended to track directly in config

PSPurchase.config(withAPIKey: "API_KEY", withAPISecret: "API_SECRET", withUserID: "USER_ID", withEmail: "USER@email.com")

Set App User ID after configuration

If your app doesn't have a user ID or email when app has started, you can set it later any time when you get it. Most commong scenarios include registration/login.

PSPurchase.shared.trackUserID("USER_ID", email: "USER@Email.com", withUsername: "USERNAME")