Tracking User

Growlytics ios SDK starts tracking users as soon as the app launches. Each time user installs app and opens for first time, Growlytics SDK automatically creates an anonymous customer for given device. All their behavioral data and session data (Events & Customer Attributes) are stored under the anonymous profile.

When customer logs-in or registers with your app's login options, all anonmous behaviour data captured earlier will be merged with logged in customer's behaviour data.

Login Customer

Use loginUser method to create a customer profile in Growlytics and sync behavioral data with this identified customer. The login method accepts two parameters:

  1. SystemId: This is the id that you use to identify customer in your system.

  2. Customer Attributes: Custom attributes you want to track for given user.

import Growlytics

class MyController: UIViewController {

    func yourLoginFunction() {
    
        /**
            Your Login Logic
        **/
        
        // Build Customer Attributes To Pass To Growlytics.
        let customerAttributes: [String:Any] = [
            // Reserved customer properties (Used in campaigns)
            name: 'John Wick',
            email: 'john@gmail.com',
            mobile: '9876543210',
            
            // Custom properties
            subscriptionType: 'pro',
            region: 'Mumbai',
            totalPurchaseTillNow: 30000
        ]
        // Login User To Growlytics.
        Analytics.getInstance().loginUser("Custome_ID", customerAttributes)
        
    }
}

Once login method is called:

  1. The user is identified (they become Known Users in your dashboard).

  2. A new, Known User Profile is created for them that contains all their data.

  3. All their previous anonymous profiles are merged with the new Known User Profile to create a single unified view of your users. (This means that data from their first visit to your website to their latest interactions can all be found under a single user profile!)

Make sure you call login as soon as the user logs in to your application, or whenever earliest you are able to identify the user.

Logout Customer

Make sure you call logout when the logged-in user logs out, or you do not want to attach any future event, session or user data with this user, until login is called again.

import Growlytics

class MyController: UIViewController {

    func yourLogoutFunction() {
    
        /**
            Your Logout Logic
        **/
        
        // Logout User From Growlytics.
        Analytics.getInstance().logoutUser()
        
    }
}

Guidelines

  • An ID can have of maximum 100 characters.

  • A user ID cannot be changed once it has been assigned.

  • Although ID can be any String that uniquely identifies users in your system, we recommend using system-generated user IDs from your database instead of information that can change over time such as email addresses, usernames, or phone numbers.

Last updated

Was this helpful?