Respecting data privacy

 

Foreword

So that you can respect user privacy and be in accordance with the regulations in different countries, the tracker makes two features available:

  • Disabling user tracking
  • Hashing user IDs
 

Disabling user tracking

If your application offers a screen allowing the user to enable or disable statistical tracking, you can save this information via the static doNotTrack method of the Tracker class.

Hits will nonetheless be sent. Only the idclient variable enabling use tracking will contain the value “opt-out”.

To change this behavior, you can use the configuration key sendHitWhenOptOut available since version 2.12.0 of the Tracker. By passing the value to false (true by default), you will prevent the hits from being sent when the user is in “opt-out” mode.

Tracker tracker = ATInternet.getInstance().getDefaultTracker();
tracker.setSendHitWhenOptOutEnabled(false, null, true);
// Tracker is now preventing hit from being sent when the user is in "opt-out" mode
 

Examples

  1. Disabling user tracking
    @Override
    public void onClick(View v) {
         // < 2.9.0 
         Tracker.doNotTrack(true); 
    
         // >= 2.9.0
         Tracker.optOut(true);
    
         // >= 2.9.1
         ATInternet.optOut(this, true);
    }

     

  2. Recovering user tracking status
    @Override
    protected void onResume() {
            super.onResume();
    
            // < 2.9.0 
            boolean doNotTrack = Tracker.doNotTrackEnabled();
          
            // >= 2.9.0
            boolean optOut = Tracker.optOutEnabled();
    
            // >= 2.9.1 
            boolean optOut = ATInternet.optOutEnabled(this);
    }
 

Hashing user ID

The SDK allows for the automatic addition of user ID in your hits (Android ID, Advertising ID). You may also add your own user ID via the tracker’s setParam method.

To ensure visitor anonymity, all while keeping their identification in your analyses, it is possible to hash the unique ID (SHA-256). To do this, use the tracker’s setConfig method as follows:

@Override
protected void onResume() {
        super.onResume();
        tracker.setConfig("hashUserId", true, new SetConfigCallback() {
            @Override
            public void setConfigEnd() {
                Log.d(null, "User ID will now be hashed");
            }
        });
}

 

 

Offline hit customization

You can configure where the offline hit are saved with the static method setDatabasePath of the ATInternet class.

If the path is incorrect, the database won’t be initialized and the offline hits will be lost

// Before any Tracker usage !
ATInternet.setDatabasePath("myCustomPath");
 

Was this post helpful?

Last update: 13/03/2019