Developers » AS2 tagging » Android » Content » Screens 2.3.0
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 Trackers dispatch method.
The method can take several different parameters:
- A character string to give a specific name
- A Context to retrieve the class name where tagging is done
Tagging examples
- Tagging a screen:
@Override protected void onResume() { super.onResume(); tracker.Screens().add("Home").sendView(); }
- Screen tagging with context:
@Override protected void onResume() { super.onResume(); tracker.Screens().add(this).sendView(); }
- Tagging a screen with a level 2:
@Override protected void onResume() { super.onResume(); tracker.Screens().add("Home").setLevel2(1).sendView(); }
- Tagging a screen with chapters:
@Override protected void onResume() { super.onResume(); tracker.Screens().add("Today News", "Home", "News").sendView(); }
- 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(); }
- Tagging a screen with use of dispatcher:
@Override protected void onResume() { super.onResume(); tracker.Screens().add("Home"); tracker.dispatch(); }
Screen class
Properties
Name | Type | Default value | Description |
---|---|---|---|
name | String | Empty string | Gets or sets the screen name |
chapter1 | String | null | Gets or sets the first chapter |
chapter2 | String | null | Gets or sets the second chapter |
chapter3 | String | null | Gets or sets the third chapter |
action | Enum | Action.View | Gets or sets the action type |
level2 | Int | -1 | Gets or sets the level 2 ID |
isBasketScreen | Bool | false | Indicates that the screen displays the content of a cart (in the case where the SalesTracker option is used) |
Publishers | PublisherImpressions | null | Class enabling the tagging of your ads impressions |
SelfPromotions | SelfPromotionImpressions | null | Class enabling the tagging of your self-promotion impressions |
CustomObjects | CustomObjects | null | Class enabling the addition of custom objects on your hits |
CustomVars | CustomVars | null | Class enabling the addition of custom variables on your screen hits |
Méthodes
Name | Return type | Description |
---|---|---|
sendView | void | Sends the screen hit |
Aisle(int level1) | Aisle | Adds an aisle |
Campaign(String campaignId) | Campaign | Adds a campaign |
setCart(Cart cart) | void | Set a cart to the screen |
Order(String orderId, double turnover) | Order | Adds an order |
Location(double latitude, double longitude) | Location | Adds location informations |
InternalSearch(String keywordLabel, int resultPageNumber) | InternalSearch | Adds internal search informations |
CustomTreeStructure(int category1) | CustomTreeStructure | Adds a custom tree |