Location

 

Foreword

If you collect and/or use your users’ geolocalisation data, you must inform these users of this data collection, the purpose of its treatment, and any possible data transfers to third parties. You must obtain the consent of the user and provide him/her the means of refusing collection and treatment of this data. You must also declare to the qualified authorities in your country that you are using localisation data in your analyses. If this data can be cross-matched with nominative personal data (measuring identified visitors with imported visitor indicators and DataExplorer subscription), you must also declare to these authorities the exact nature of the cross-matchable data.

You can add geolocalisation data (latitude, longitude) in a screen hit.

Only the two first digits after the decimal separator will be taken into account.

 

Get off to a good start

Once your tag is initialised, you can add geolocalisation data to your screen hits.

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

 

Tagging examples

  1. Tagging a screen with geolocalisation data
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    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("Map");
            s.Location(21.03, 177.76);
            s.sendView();
        }
    }
  2. Tagging a screen with geolocalisation data and use of dispatcher
    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;
    
    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();
            Screen s = tracker.Screens().add("Map");
            // Add location to next screen hit
            s.Location(21.03, 177.76);
            // Add a custom object
            s.CustomObjects().add(new HashMap<String, Object>() {{
                put("country", "fr");
            }});
            // Add a custom variable
            s.CustomVars().add(1, "fr", CustomVar.CustomVarType.Screen);
            // Track a screen with name Map
            s.setLevel2(1);
            // Send screen hit
            tracker.dispatch();
        }
    }
 

Location class

 

Properties

NameTypeDefault valueDescription
latitudeDouble-1.0Gets or sets latitude
longitudeDouble-1.0Gets or sets longitude
Last update: 05/04/2018