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.

How User Profiles are Merged When User is Identified (assigned a CUID by you)

Let's assume that User A visits your website a few times before signing up.

User A visits your website on Day 1: Growlytics assigns them an LUID and automatically creates an anonymous user profile containing all their data (Anonymous Profile 1).

User A revisits your website on Day 3: Growlytics assigns them an LUID and creates another anonymous profile to record all their data (Anonymous Profile 2).

User A revisits your website on Day 7 and creates an account: On account creation, you can choose to assign the user a CUID. This will lead to the creation of a new user profile.

  • As soon as the Known User Profile is created, Growlytics will run a quick check in it's backend to identify all the existing anonymous user profiles of the user that were created on their previous visits.

  • In this case, Anonymous Profile 1 and Anonymous Profile 2 will be merged with the final profile of User A to provide a unified view of their preferences and behavioral history.

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