Create Content

Form tracking is available in native Android applications as of SDK version 5.0.1. Form tracking allows customers to get in depth information of form input by users and indicates if a user filled out (filled out or value of field) a particular form field or not (empty value).

Trackable Field Types

Currently, input of the following field types can be tracked:

  • EditText
    • Plain
    • Multiline
    • AutoComplete
    • MultiAutoComplete
    • Email
    • Address
    • Phone
    • Password
    • Number
  • Time
  • Date
  • SearchView
  • RadioButton
  • ToggleButton
  • Switch
  • CheckBox
  • RatingBar
  • Spinner

Methods and Properties

Name of Function

formTracking(
        context: Context,
        view: View? = null,
        formTrackingSettings: FormTrackingSettings = FormTrackingSettings()
    )
AttributeDescriptionMandatory
contextThe context of the current activity.yes
viewOverrides the local view used in the activity.no
formTrackingSettingsAdditional settings to customise form trackingno

Configuration

Set the form tracking configuration.

  • formName: By default, the name of the current activity or view is used as the name of the form. Use this function to specify a different name for the form.
  • fieldIds: If you want to track only specific fields of the form, indicate them here. Otherwise, all trackable fields of the current activity or view are tracked.
  • renameFields: By default, the name of the field ID is used to generate the name of the field. If you want to change the default name you can specify this here.
  • changeFieldsValue: By default, the value of the text field is used as value of the field. You can change the default value here. Please be aware that if hardcoded, the field value is changed permanently and does not indicate anymore if a field was left empty.
  • anonymousSpecificFields: By default, only EditText fields are anonymised and send as filled out or empty  to the trackserver, instead of displaying the actual value of the field. If other field types need to be anonymised, you can indicate them here.
  • fullContentSpecificFields: By default, the SDK sends EditText fields anonymised (filled out / empty) to Mapp Intelligence. If you want to send the actual content of the specific fields instead, indicate them here.
  • confirmButton: If you want to indicate that a form has been submitted or cancelled, you can set the confirmButton to true or false. By default, the confirmButton is set to true.
  • anonymous: If you want to anonymise all field types, set anonymous to true.
  • pathAnalysis: You can track the order in which the user has filled out the fields. Please note that you need to track the order manually and parse the data to the fieldsOrder function. Mapp Intelligence cannot track the order in which the user filled out the form automatically.


data class FormTrackingSettings(
    var formName: String = "",
    var fieldIds: List<Int> = emptyList(),
    var renameFields: Map<Int, String> = emptyMap(),
    var changeFieldsValue: Map<Int, String> = emptyMap(),
    var anonymousSpecificFields: List<Int> = emptyList(),
    var fullContentSpecificFields: List<Int> = emptyList(),
    var confirmButton: Boolean = true,
    var anonymous: Boolean = true,
    var pathAnalysis: List<Int> = emptyList()
)

Example

// set form tracking config for confirmation and cancellation of form
class FormActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.form_main)

        //Set a listener on the cancel button of a form
		cancel.setOnClickListener {
            val form = FormTrackingSettings()
            form.confirmButton = false //confirm button is 
            form.formName = "test123"
            form.anonymous = true
            form.anonymousSpecificFields = listOf(R.id.editText, R.id.editText3, R.id.switch1)
            form.fullContentSpecificFields = listOf(R.id.editText2)
            Webtrekk.getInstance().formTracking(this, formTrackingSettings = form)
        }

		//Set a listener on the confirm button of a form
        confirm.setOnClickListener {
            val form = FormTrackingSettings()
            form.confirmButton = true
            form.formName = "test123"
            form.anonymous = true
            form.anonymousSpecificFields = listOf(R.id.editText2)
            form.fullContentSpecificFields = listOf(R.id.editText, R.id.editText3, R.id.switch1)
            Webtrekk.getInstance().formTracking(this, formTrackingSettings = form)
        }
    }
}

// configure specific view
val view =
    findViewById<View>(android.R.id.content).rootView
Webtrekk.getInstance().formTracking(this,view=view)

// configure form name
val form= FormTrackingSettings()
form.formName="My Form"
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// congfigure to track only specific fields
val form= FormTrackingSettings()
form.fieldsOrder= listOf(R.id.editText2,R.id.editText)
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// rename fields
val form= FormTrackingSettings()
form.renameFields=mapOf(Pair(R.id.editText2,"Named text view"))
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// anonymise specific fields
val form= FormTrackingSettings()
form.anonymousSpecificFields=listOf(R.id.switch1)
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// anonymise all fields
val form= FormTrackingSettings()
form.anonymous=true
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// show full content of specific fields
val form= FormTrackingSettings()
form.fullContentSpecificFields=listOf(R.id.editText1)
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// change value of fields
val form= FormTrackingSettings()
form.changeFieldsValue=mapOf(Pair(R.id.editText2,"New value")) // this needs to be filled dynamically!
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// set confirm button to false
val form= FormTrackingSettings()
form.confirmButton=false
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)

// track path analysis 
val form= FormTrackingSettings()
form.pathAnalysis= listOf(R.id.editText2,R.id.editText,R.id.editText3) //this needs to be filled dynamically!
Webtrekk.getInstance().formTracking(this,formTrackingSettings=form)
// set form tracking config for confirmation and cancellation of form
public class FormActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
    private Button cancel;
    private Button confirm;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.form_main);
        
        //Set a listener on the cancel button of a field
        cancel = findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FormTrackingSettings form = new FormTrackingSettings();
                form.setConfirmButton(false);
                form.setFormName("test123");
                form.setAnonymous(true);
                form.setAnonymousSpecificFields(Arrays.asList(R.id.editText, R.id.editText3, R.id.switch1));
                form.setFullContentSpecificFields(Arrays.asList(R.id.editText2));
                Webtrekk.getInstance().formTracking(FormActivity.this, null, form);
            }
        });

        //Set a listener to the confirm button of a field
        confirm = findViewById(R.id.confirm);
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FormTrackingSettings form = new FormTrackingSettings();
                form.setConfirmButton(true);
                form.setFormName("test123");
                form.setAnonymous(false);
                form.setAnonymousSpecificFields(Arrays.asList(R.id.editText2));
                form.setFullContentSpecificFields(Arrays.asList(R.id.editText, R.id.editText3, R.id.switch1));
                Webtrekk.getInstance().formTracking(FormActivity.this, null, form);
            }
        });
	}
}

        
// Configure specific view
View view = findViewById(android.R.id.content).getRootView();
Webtrekk.getInstance().formTracking(this, view, new FormTrackingSettings());

// Configure form name
FormTrackingSettings form = new FormTrackingSettings();
form.setFormName("My Form");
Webtrekk.getInstance().formTracking(this, null, formOne);

// Configure to track only specific fields
FormTrackingSettings form = new FormTrackingSettings();
form.setFieldIds(Arrays.asList(R.id.editText2, R.id.editText));
Webtrekk.getInstance().formTracking(this, null, formTwo);

// Rename fields
FormTrackingSettings form = new FormTrackingSettings();
form.setRenameFields(new LinkedHashMap<Integer, String>() {{
	put(R.id.editText2, "Named text view");
}});
Webtrekk.getInstance().formTracking(this, null, formThree);

// Anonymize specific fields
FormTrackingSettings form = new FormTrackingSettings();
form.setAnonymousSpecificFields(Arrays.asList(R.id.switch1));
Webtrekk.getInstance().formTracking(this, null, formFour);

// Anonymize all fields
FormTrackingSettings form = new FormTrackingSettings();
form.setAnonymous(true);
Webtrekk.getInstance().formTracking(this, null, formFive);

// Show full content of specific fields
FormTrackingSettings form = new FormTrackingSettings();
form.setFullContentSpecificFields(Arrays.asList(R.id.editText));
Webtrekk.getInstance().formTracking(this, null, formSix);

// Change value of fields
FormTrackingSettings form = new FormTrackingSettings();
form.setChangeFieldsValue( new LinkedHashMap<Integer, String>() {{
	put(R.id.editText2, "New Value");
}}); // this needs to be filled dynamically!
Webtrekk.getInstance().formTracking(this, null, formSeven);

// Set confirm button to false
FormTrackingSettings form = new FormTrackingSettings();
form.setConfirmButton(false);
Webtrekk.getInstance().formTracking(this, null, formEight);

// Track path analysis
FormTrackingSettings form = new FormTrackingSettings();
form.setPathAnalysis(Arrays.asList(R.id.editText2,R.id.editText,R.id.editText3)); //this needs to be filled dynamically!
Webtrekk.getInstance().formTracking(this, null, formNine);

Additional Resources

Please also check our sample application inside our Android SDK v5 version to try out form tracking in a sample app. You can download the SDK in GitHub.

Known Limitations

  • Last Focus does not work faultlessly and only for editText types.
  • pathAnalysis and rename fields do not work automatically.