Screens

 

Get off to a good start

Once your tag is initialised, you can start tagging your screens.

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

Declare a Tracker-type variable in your Activity

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();
    }
}
 

Tagging

To tag a screen, the tracker exposes a screens object.

Two solutions are available to tag a screen:

  • Define one or several tagging and send the hit(s) at the desired moment
  • Send screen tagging directly

To do this, the screens object of the Tracker class offers an add method.
This method enables the addition of screen tagging which can be sent at the desired moment (e.g. onCreate, onResume…).

The add method sends back a Screen-type object. To send the defined information, you must manually call the sendView method of your Screen object, or call the Tracker’s dispatch method.

The method can take several different parameters:

  1. A character string to give a specific name
  2. A Context to retrieve the class name where tagging is done
 

Tagging examples

  1. Tagging a screen:
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Screens().add("Home").sendView();
    }
  2. Screen tagging with context:
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Screens().add(this).sendView();
    }
  3. Tagging a screen with a level 2:
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Screens().add("Home").setLevel2(1).sendView();
    }
  4. Tagging a screen with chapters:
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Screens().add("Today News", "Home", "News").sendView();
    }
  5. Screen tagging with addition of a custom object: In this example, the name of the screen is not entered because it is possible to put the name in the stc parameter in order to use it with DataManager.
    @Override
    protected void onResume() {
            super.onResume();
            Screen s = tracker.Screens().add(this);
            s.CustomObjects().add(new HashMap<String, Object>() {{
                put("page", "Home");
            }});
            s.sendView();
    }
    
  6. Tagging a screen with use of dispatcher:
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Screens().add("Home");
            tracker.dispatch();
    }
 

Screen class

 

Properties

NameTypeDefault valueDescription
nameStringEmpty stringGets or sets the screen name
chapter1StringnullGets or sets the first chapter
chapter2StringnullGets or sets the second chapter
chapter3StringnullGets or sets the third chapter
actionEnumAction.ViewGets or sets the action type
level2Int-1Gets or sets the level 2 ID
isBasketScreenBoolfalseIndicates that the screen displays the content of a cart (in the case where the SalesTracker option is used)
PublishersPublisherImpressionsnullClass enabling the tagging of your ads impressions
SelfPromotionsSelfPromotionImpressionsnullClass enabling the tagging of your self-promotion impressions
CustomObjectsCustomObjectsnullClass enabling the addition of custom objects on your hits
CustomVarsCustomVarsnullClass enabling the addition of custom variables on your screen hits
 

Méthodes

NameReturn typeDescription
sendViewvoidSends the screen hit
Aisle(int level1)AisleAdds an aisle
Campaign(String campaignId)CampaignAdds a campaign
setCart(Cart cart)voidSet a cart to the screen
Order(String orderId, double turnover)OrderAdds an order
Location(double latitude, double longitude)LocationAdds location informations
InternalSearch(String keywordLabel, int resultPageNumber)InternalSearchAdds internal search informations
CustomTreeStructure(int category1)CustomTreeStructureAdds a custom tree
Last update: 13/03/2018