Ads

  • iOS
  • watchOS
  • tvOS
 

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.

 

Get off to a good start

Once your tag is initialised, you can start tagging your in-app ads.

Dans le cas d’un projet Swift, veillez à importer le module SmartTracker (ou tvOSTracker / watchOSTracker si votre target est une Apple TV / Apple watch) dans votre ViewController. Dans le cas d’un projet Objective-C, veillez à importer les entêtes SmartTracker-Swift.h

 

Tagging

To tag your ads, the tracker exposes two properties, publishers and selfPromotions, according to the type of ad to be measured.

These two properties 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’dispatch method.

Please note, calling the methods sendTouch and sendImpression modifies the object’s action property.

The sendImpressions method allows sending of all information for ads whose action is defined as Impression.

 

Tagging examples

  1. Tagging an ad impression for a third-party

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
           tracker.publishers.add("[ad1]").sendImpression()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [[self.tracker.publishers add:@"[ad1]"] sendImpression];
    }
    
    @end
  2. Tagging an ad “click” for a third-party

    @IBAction func touchAd(sender: UIButton) {
        ATInternet.sharedInstance.defaultTracker.publishers.add("[ad1]").sendTouch()
    }
    - (IBAction)touchAd:(UIButton *)sender {
        [[[ATInternet sharedInstance].defaultTracker.publishers add:@"[ad1]"] sendTouch];
    }
  3. Tagging a self-promotion campaign impression

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
           tracker.selfPromotions.add(1).sendImpression()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [[self.tracker.selfPromotions add:1] sendImpression];
    }
    
    @end
  4. Tagging an self-promotion campaign “click”

    @IBAction func touchAd(sender: UIButton) {
        ATInternet.sharedInstance.defaultTracker.selfPromotions.add(1).sendTouch()
    }
    - (IBAction)touchAd:(UIButton *)sender {
        [[[ATInternet sharedInstance].defaultTracker.selfPromotions add:1] sendTouch];
    }
  5. Tagging several ads and sending impressions

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
            let ad1 = tracker.publishers.add("[ad1]")
            ad1.creation = "[creation]"
            ad1.variant = "[variant]"
            ad1.format = "[120x40]"
            ad1.generalPlacement = "[generalPlacement]"
            ad1.detailedPlacement = "[detailedPlacement]"
            ad1.advertiserId = "1[advertiserId]"
            ad1.url = "[http://avertiser-url.com]"
            
            tracker.publishers.add("[ad2]")
            
            let ad3 = tracker.publishers.add("[ad3]")
            ad3.creation = "[creation]"
            ad3.variant = "[variant]"
            
            tracker.publishers.sendImpressions()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        Publisher *ad1 = [self.tracker.publishers add:@"[ad1]"];
        ad1.creation = @"[creation]";
        ad1.variant = @"[variant]";
        ad1.format = @"[120x40]";
        ad1.generalPlacement = @"[generalPlacement]";
        ad1.detailedPlacement = @"[detailedPlacement]";
        ad1.advertiserId = @"1[advertiserID]";
        ad1.url = @"[http://avertiser-url.com]";
        
        [self.tracker.publishers add:@"[ad2]"];
        
        Publisher *ad3 = [self.tracker.publishers add:@"[ad3]"];
        ad3.creation = @"[creation]";
        ad3.variant = @"[variant]";
        
        [self.tracker.publishers sendImpressions];
    }
    
    @end
  6. Tagging several self-promotion campaigns and sending impressions

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
            let sp1 = tracker.selfPromotions.add(1)
            sp1.format = "[120x40]"
            sp1.productId = "p1"
    
            tracker.selfPromotions.add(2)
            
            let sp3 = tracker.selfPromotions.add(3)
            sp3.productId = "p3"
            
            tracker.selfPromotions.sendImpressions()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        SelfPromotion *sp1 = [self.tracker.selfPromotions add:1];
        sp1.format = @"[120x40]";
        sp1.productId = @"p1";
        
        [self.tracker.selfPromotions add:2];
        
        SelfPromotion *sp3 = [self.tracker.selfPromotions add:3];
        sp3.productId = @"p3";
        
        [self.tracker.selfPromotions sendImpressions];
    }
    
    @end
  7. Tagging self-promotion ads and campaigns and using dispatcher

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
            tracker.publishers.add("[ad1]")
            tracker.publishers.add("[ad2]")
            tracker.selfPromotions.add(1)
    
            // This will send one hit with publishers and selfpromotion impressions
            tracker.dispatch()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.publishers add:@"[ad1]"];
        [self.tracker.publishers add:@"[ad2]"];
        [self.tracker.selfPromotions add:1];
    
        // This will send one hit with publishers and selfpromotion impressions
        [self.tracker dispatch];
    }
    
    @end
  8. Tagging self-promotion ads and campaigns and adding screen information

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(animated: Bool) {
            tracker.publishers.add("[ad1]")
            tracker.publishers.add("[ad2]")
            tracker.selfPromotions.add(1)
            tracker.screens.add("Home").sendView()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.publishers add:@"[ad1]"];
        [self.tracker.publishers add:@"[ad2]"];
        [self.tracker.selfPromotions add:1];
        [[self.tracker.screens add:@"Home"] sendView];
    }
    
    @end
  9. Tagging a screen impression

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {
            let screen = tracker.screens.add("Home")
            _ = screen.publishers.add("[ad1]")
            screen.sendView()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        Screen *screen = [[self.tracker screens] add:@"Home"];
        [screens.publishers add:@"[ad1]"];
        [screen sendView];
    }
    
    @end
 

Publisher class

 

Properties

Nom Type Valeur par défaut Description
campaignId String Chaîne vide Gets or sets the campaign name (ex: [label] or id[label])
creation String? nil Gets or sets the creative name (ex: [label] or id[label])
variant String? nil Gets or sets the variant name (ex: [label] or id[label])
format String? nil Gets or sets the format name (predefined or custom ID. ex: [120×40])
generalPlacement String? nil Gets or sets the general placement (textual ID predefined by us, to be formatted as [label])
detailedPlacement String? nil Gets or sets the detailed placement (ex: [label] or id[label])
advertiserId String? nil Gets or sets the advertiser ID (ex: id[label])
url String? nil Gets or sets the URL to which the link points. The URL is necessarily linked to the advertiser ID
action Enum OnAppAd.Action.View Obtient ou définit le type d’action (View ou Touch)
 

Methods

Nom Type de retour 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 Valeur par défaut Description

adId

Int 0 Gets or sets the ad ID
format String? nil Gets or sets the format name (predefined or custom ID. ex: [120×40])
productId String? nil 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)
 

Methods

Nom Type de retour 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
 

Was this post helpful?

Last update: 13/12/2016