Developers » AS2 tagging » Android » Campaigns » On-site ads 2.3.0
On-site ads
Foreword
AT Internet’s SDK offers the measurement of your in-app ads so that you can evaluate their performance.
The goal is to measure “clicks” and impressions of self-promotion ad campaigns, as well as third-party campaigns displayed on your app, and then analyse this information.
To be sure to measure properly the Auto-Promotion campaign, please check if your campaign is declared in Settings > Marketing campaigns.
Get off to a good start
Once your tag is initialised, you can start tagging your in-app ads.
If you want to use variables, be sure to import ATInternet, Tracker, SelfPromotion and Publisher classes in your Activity.
Tagging
To tag your ads, the tracker exposes two objects, publishers and selfPromotions, according to the type of ad to be measured.
These two objects themselves expose two methods:
- add
- sendImpressions
The add method allows you to add an ad tag and put it in standby for send. This method returns an object with type Publisher or SelfPromotion according to the case in question.
To send the defined information, you must call the sendTouch or sendImpression method of your object, based on the type of action taken by the user, or call the Tracker‘s dispatch method.
Please note, calling the methods sendTouch and sendImpression modifies the object’s action property.
The sendImpressions method is used to send all ad data which action is defined as Impression.
The sendTouch and sendImpression methods are available only through the objects Publisher or SelfPromotion returned by the Add method.
They lead to an instantaneous and independent sending (click or impression) of the newly added ad tag.
Example@Override protected void onResume() { super.onResume(); tracker.SelfPromotions().add(1).sendImpression(); }The sendImpressions method is available through Publishers and SelfPromotions objects.
It allows a global sending of all impression-type ad tags that have been previously added.
Example@Override protected void onResume() { super.onResume(); tracker.SelfPromotions().add(1); tracker.SelfPromotions().add(2); tracker.SelfPromotions().sendImpressions(); }
Tagging examples
- Tagging an ad impression for a third-party
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(); tracker.Publishers().add("[ad1]").sendImpression(); } }
- Tagging an ad “click” for a third-party
@Override public void onClick(View v) { ATInternet.getInstance().getDefaultTracker().Publishers().add("[ad1]").sendTouch(); }
- Tagging a self-promotion campaign impression
package com.atinternet.atinternetdemo; import android.app.Activity; import android.os.Bundle; import com.atinternet.tracker.ATInternet; import com.atinternet.tracker.Debugger; 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(); tracker.SelfPromotions().add(1).sendImpression(); } }
- Tagging an self-promotion campaign “click”
@Override public void onClick(View v) { ATInternet.getInstance().getDefaultTracker().SelfPromotions().add(3).sendTouch(); }
- Tagging several ads and sending impressions
50 impressions per page maximum
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(); tracker.Publishers().add("[ad1]") .setCreation("[creation]") .setVariant("[variant]") .setFormat("[120x40]") .setGeneralPlacement("[generalPlacement]") .setDetailedPlacement("[detailedPlacement]") .setAdvertiserId("1[advertiserId]") .setUrl("[http://advertiser-url.com]"); tracker.Publishers().add("[ad2]"); tracker.Publishers().add("[ad3]") .setCreation("[creation]") .setVariant("[variant]"); tracker.Publishers().sendImpressions(); } }
- Tagging several self-promotion campaigns and sending impressions
package com.atinternet.atinternetdemo; import android.app.Activity; import android.os.Bundle; import com.atinternet.tracker.ATInternet; import com.atinternet.tracker.Debugger; 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(); tracker.SelfPromotions().add(1) .setFormat("[120x40]") .setProductId("p1"); tracker.SelfPromotions().add(2); tracker.SelfPromotions().add(3) .setProductId("p3"); tracker.SelfPromotions().sendImpressions(); } }
- Tagging self-promotion ads and campaigns and using dispatcher
package com.atinternet.atinternetdemo; import android.app.Activity; import android.os.Bundle; import com.atinternet.tracker.ATInternet; import com.atinternet.tracker.Debugger; 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(); tracker.Publishers().add("[ad1]"); tracker.Publishers().add("[ad2]"); tracker.SelfPromotions().add(1); // This will send one hit with publishers and selfpromotion impressions tracker.dispatch(); } }
- Tagging self-promotion ads and campaigns and adding screen information
package com.atinternet.atinternetdemo; import android.app.Activity; import android.os.Bundle; import com.atinternet.tracker.ATInternet; import com.atinternet.tracker.Debugger; 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(this); s.Publishers().add("[ad1]"); s.Publishers().add("[ad2]"); s.SelfPromotions().add(1); s.sendView(); } }
Publisher class
Properties
Name | Type | Default value | Description |
---|---|---|---|
campaignId | String | Empty string | Gets or sets the campaign name (ex: [label] or id[label]) |
creation | String | null | Gets or sets the creative name (ex: [label] or id[label]) |
variant | String | null | Gets or sets the variant name (ex: [label] or id[label]) |
format | String | null | Gets or sets the format name (predefined or custom ID. ex: [120×40]) |
generalPlacement | String | null | Gets or sets the general placement (textual ID predefined by us, to be formatted as [label]) |
detailedPlacement | String | null | Gets or sets the detailed placement (ex: [label] or id[label]) |
advertiserId | String | null | Gets or sets the advertiser ID (ex: id[label]) |
url | String | null | Gets or sets the URL linked (ex: [url] |
action | Enum | OnAppAd.Action.View | Gets or sets the action type (View or Touch) |
CustomObjects | CustomObjects | null | Class enabling the addition of custom objects on your hits |
Methods
Name | Return type | Description |
---|---|---|
sendTouch | void | Sends a hit indicating that an ad was touched |
sendImpression | void | Sends a hit indicating that an ad was seen |
SelfPromotion class
Properties
Nom | Type | Default value | Description |
---|---|---|---|
adId | Int | -1 | Gets or sets the ad ID |
format | String | null | Gets or sets the format name (predefined or custom ID. ex: [120×40]) |
productId | String | null | Gets or sets the self-promoted product in question, that can be found in the order (Subject to the SalesTracker option) |
action | Enum | OnAppAd.Action.View | Gets or sets the action type (View or Touch) |
CustomObjects | CustomObjects | null | Class enabling the addition of custom objects on your hits |
Methods
Name | Return type | Description |
---|---|---|
sendTouch | void | Sends a hit indicating that a self-promotion campaign was touched |
sendImpression | void | Sends a hit indicating that a self-promotion campaign was seen |