Custom screen and application variables

 

Foreword

Custom application variables allow you to associate information with a user’s activity while s/he is using your application.

Custom screen variables focus on a view in particular, and allow you, notably, to tag the fields of an entry form.

 

Get off to a good start

Once your tag is initialised, you can add your custom variables to your screen hit.

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

 

Tagging

The Screen object makes available a CustomVars-type object that exposes an add method. This method accepts three parameters:

  • varId: index of the indicator
  • value: value of the indicator, character string in the format:
    • text: [lorem]
    • decimal: “,” or “.” separator, two characters maximum after the separator
    • date: yyyymmdd
    • country: ISO
    • duration: integer
  • type: type of indicator
 

Tagging example

  1. Site indicator, with a date value
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.CustomVar;
    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();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            Screen s = tracker.Screens().add("My Screen with Custom Var");
            s.CustomVars().add(1, "2014224", CustomVar.CustomVarType.App);
            s.sendView();
        }
    }
  2. Screen indicator, with a text value
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.CustomVar;
    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();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            Screen s = tracker.Screens().add("My Screen with Custom Var");
            s.CustomVars().add(1, "[object]", CustomVar.CustomVarType.Screen);
            s.sendView();
        }
    }
 

CustomVar class

 

Properties

NameTypeDefault valueDescription
varIdInt-1Gets or sets the variable ID
typeEnumCustomVarType.AppGets or sets the variable type
valueStringEmpty stringGets or sets the variable value
Last update: 05/04/2018