Level 2s

 

Foreword

AT Internet’s SDK offers you the possibility to “separate” your application into different sections (called “level 2s”). These level 2s allow you to better target certain parts of your application in order to zoom in on how these parts are used.

 

Get off to a good start

Once your tag is initialised, you can modify the level 2 ID used in the sending of hits.

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

 

Tagging

The SDK allows you to modify the level 2 ID that will be sent during a screen hit, a gesture hit… You Can also modify the level 2 ID in a more “global” manner for permanent use.

The tracker possesses a context object which itself possesses a level2 subproperty. By default, this property has a value of 0. By editing this property’s value, the level 2 ID will be added in to future hits.

To disable this feature, simply reset the ID to 0.

 

Tagging examples

In these examples, we’ll consider the addition of level 2 information on screen tagging.

  1. Setup of a level 2 when a user enters a particular section of the app
    @Override
    protected void onResume() {
            super.onResume();
            ATInternet.getInstance().getDefaultTracker().Context().setLevel2(1);
            ATInternet.getInstance().getDefaultTracker().Screens().add(this).sendView();
    }
  2. Delete tracker’s level 2 by default when screen is changed
    @Override
    protected void onStop() {
            super.onStop();
            ATInternet.getInstance().getDefaultTracker().Context().setLevel2(0);
    }
  3. Override a level 2 for a hit
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Tracker;
    
    
    public class MainActivity extends Activity implements View.OnClickListener {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            findViewById(R.id.text).setOnClickListener(this);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            ATInternet.getInstance().getDefaultTracker().Context().setLevel2(1);
            ATInternet.getInstance().getDefaultTracker().Screens().add(this).sendView();
        }
    
        @Override
        public void onClick(View v) {
            tracker.Gestures().add("ButtonTouch").setLevel2(2).sendTouch();
        }
    }
Last update: 05/04/2018