Developers » AS2 tagging » Apple » Ecommerce » SalesTracker » Produits 2.1.0
Produits
- iOS
- watchOS
- tvOS
Avant-propos
Le SDK AT Internet vous permet de marquer les produits proposés à la vente, vus par vos utilisateurs durant l’utilisation de votre application.
La mesure des produits vus nécessite l’activation d’une option. Veuillez contacter le centre support pour plus d’informations.
Pour bien débuter
Une fois votre marqueur initialisé, vous pouvez envoyer les informations de produits vus.
Dans le cas d’un projet Swift, veillez à importer le module Tracker (ou TrackerExtension si votre target est une extension) dans votre ViewController. Dans le cas d’un projet Objective-C, veillez à importer les entêtes ATInternet.h, ATTracker.h, ATProduct.h
Marquage
Le tracker met à disposition une propriété products. Cette propriété expose les méthodes suivantes :
- add (ou addString en Objective-C) : Ajoute un produit vu à la liste et retourne un objet Product
- remove : Supprime un produit vu de la liste
- removeAll : Supprime tous les produits vus
- sendViews : Envoie les informations sur les produits vus
Exemples de marquage
- Marquage d’un produit vu
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(animated: Bool) { tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]").sendView() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[self.tracker.products add:@"1253[MF885FA]" category1:@"1[Desktop]" category2: @"10[iMac]"] sendView]; } @end
- Marquage de plusieurs produits vus
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(animated: Bool) { tracker.products.add("1254[MF839FA]", category1: "2[Laptop]", category2: "20[Macbook Pro]") tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]") tracker.products.sendViews() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tracker.products add:@"1254[MF839FA]" category1: @"2[Laptop]" category2: @"20[Macbook Pro]"]; [self.tracker.products add:@"1253[MF885FA]" category1: @"1[Desktop]" category2: @"10[iMac]"]; [self.tracker.products sendViews]; } @end
- Marquage de produits vus avec ajout d’un produit au panier
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker var products: [Product] = [] override func viewDidLoad() { super.viewDidLoad() // Enable cart and set an ID tracker.cart.set("1") // Declare first product let p1 = tracker.products.add("1254[MF839FA]", category1: "2[Laptop]", category2: "20[Macbook Pro]") p1.quantity = 1 p1.unitPriceTaxFree = 1839 p1.unitPriceTaxIncluded = 2299 products.append(p1) // Declare second product let p2 = tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]") p2.quantity = 1 p2.unitPriceTaxFree = 1199 p2.unitPriceTaxIncluded = 1499 products.append(p2) } override func viewWillAppear(animated: Bool) { // Send products views tracker.products.sendViews() // Send screen hit tracker.screens.add("Store").sendView() } @IBAction func addProductToCart(sender: UIButton) { // Add a previously declared product to the cart tracker.cart.products.add(products[0]) } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Go to cart resume and send a screen hit with cart content let cartScreen = tracker.screens.add("Cart resume") // If isBasketScreen is not set to true, Cart info won't be added to Screen hit cartScreen.isBasketScreen = true cartScreen.sendView() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATScreen.h" #import "ATCart.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @property (nonatomic, strong) NSMutableArray* products; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; self.products = [[NSMutableArray alloc] init]; [self.tracker.cart setWithId:@"1"]; ATProduct *p1 = [self.tracker.products add:@"1254[MF839FA]" category1: @"2[Laptop]" category2: @"20[Macbook Pro]"]; p1.quantity = 1; p1.unitPriceTaxFree = 1839; p1.unitPriceTaxIncluded = 2299; [self.products addObject:p1]; ATProduct *p2 = [self.tracker.products add:@"1253[MF885FA]" category1: @"1[Desktop]" category2: @"10[iMac]"]; p2.quantity = 1; p2.unitPriceTaxFree = 1149; p2.unitPriceTaxIncluded = 1499; [self.products addObject:p2]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // Send products views [self.tracker.products sendViews]; [[self.tracker.screens addWithName:@"Store"] sendView]; } - (IBAction) addProductToCart:(UIButton *)sender { // Add a previously declared product to the cart [self.tracker.cart.products add:self.products[0]]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Go to cart resume and send a screen hit with cart content ATScreen* cartScreen = [self.tracker.screens addWithName:@"Cart resume"]; // If isBasketScreen is not set to true, Cart info won't be added to Screen hit cartScreen.isBasketScreen = YES; [cartScreen sendView]; } @end
- Suppression d’un produit
@IBAction func removeProduct(sender: UIButton) { tracker.products.remove("1254[MF839FA]") }
- (IBAction) removeProduct:(UIButton *)sender { [self.tracker.products removeWithId:@"1254[MF839FA]"]; }
- Suppression de tous les produits
@IBAction func removeProducts(sender: UIButton) { tracker.products.removeAll() }
- (IBAction) removeProducts:(UIButton *)sender { [self.tracker.products removeAll]; }
Classe Product
Propriétés
Nom | Type | Valeur par défaut | Description |
---|---|---|---|
productId | String | Chaîne vide | Obtient ou définit l’identifiant du produit |
category1 | String? | nil | Obtient ou définit la 1ère catégorie du produit |
category2 | String? | nil | Obtient ou définit la 2nde catégorie du produit |
category3 | String? | nil | Obtient ou définit la 3ème catégorie du produit |
category4 | String? | nil | Obtient ou définit la 4ème catégorie du produit |
category5 | String? | nil | Obtient ou définit la 5ème catégorie du produit |
category6 | String? | nil | Obtient ou définit la 6ème catégorie du produit |
quantity | Int? | nil | Obtient ou définit la quantité de produit |
unitPriceTaxIncluded | Double? | nil | Obtient ou définit le prix unitaire TTC |
unitPriceTaxFree | Double? | nil | Obtient ou définit le prix unitaire HT |
discountTaxIncluded | Double? | nil | Obtient ou définit le montant de remise TTC |
discountTaxFree | Double? | nil | Obtient ou définit le montant de remise HT |
promotionalCode | String? | nil | Obtient ou définit le code promotionnel pour le produit |