Identified visitors

 

Foreword

Identified visitors are the visitors you’re able to recognise following authentication (sign up, subscription, sign in…). These visitors can be regrouped into categories to give you a greater overall view during your analyses.

A visitor can be identified with a numerical or textual ID.

If different values are recorded in the same visit, only the first one will be taken into account

 

Get off to a good start

Once your tag is initialised, you can add visitor identification information.

If you want to use variables, be sure to import ATInternet, Tracker and IdentifiedVisitor classes in your Activity.

 

Tagging

The tracker possesses an identifiedVisitor object. This object offers a group of methods for enabling or disabling visitor identification. This type of tagging is persistent by default, meaning that even if the application is exited, the visitor identification data will be present in the hits, once the application is reopened. In “non persistent” mode, data will be automatically erased once the application is exited. It is also possible to manually delete identification data.

 

Tagging examples

  1. Tagging a screen with a numerical visitor ID
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Debugger;
    import com.atinternet.tracker.Tracker;
    
    import java.util.HashMap;
    
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.IdentifiedVisitor().set(123456);
            tracker.Screens().add("My Account").sendView();
        }
    }
  2. Tagging a screen with a numerical ID and a category
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Debugger;
    import com.atinternet.tracker.Tracker;
    
    import java.util.HashMap;
    
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.IdentifiedVisitor().set(123456, 6);
            tracker.Screens().add("My Account").sendView();
        }
    }
  3. Tagging a screen with the addition of a textual visitor ID
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Debugger;
    import com.atinternet.tracker.Tracker;
    
    import java.util.HashMap;
    
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.IdentifiedVisitor().set("user12345");
            tracker.Screens().add("My Account").sendView();
        }
    }
  4. Tagging a screen with the addition of a textual ID and a category
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Debugger;
    import com.atinternet.tracker.Tracker;
    
    import java.util.HashMap;
    
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.IdentifiedVisitor().set("user12345", 87);
            tracker.Screens().add("My Account").sendView();
        }
    }
  5. To disable visitor identification (e.g. when a user logs off)
    private void logOut() {
            ATInternet.getInstance().getDefaultTracker().IdentifiedVisitor().unset();
    }
  6. Disabling persistent mode
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.SetConfigCallback;
    import com.atinternet.tracker.Tracker;
    
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
            tracker.setConfig("persistIdentifiedVisitor", false, new SetConfigCallback() {
                @Override
                public void setConfigEnd() {
                    Log.d(null, "Visitor id won't be persisted anymore");
                }
            });
        }
    }
 

Was this post helpful?

Last update: 27/02/2019