Developers » Apple » Ecommerce » 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
12345678910111213141516import UIKitimport Trackerclass ViewController: UIViewController {let tracker: Tracker = ATInternet.sharedInstance.defaultTrackeroverride func viewDidLoad() {super.viewDidLoad()}override func viewWillAppear(animated: Bool) {tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]").sendView()}}1234567891011121314151617181920212223242526#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
123456789101112131415161718import UIKitimport Trackerclass ViewController: UIViewController {let tracker: Tracker = ATInternet.sharedInstance.defaultTrackeroverride 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()}}1234567891011121314151617181920212223242526272829#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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import UIKitimport Trackerclass ViewController: UIViewController {let tracker: Tracker = ATInternet.sharedInstance.defaultTrackervar products: [Product] = []override func viewDidLoad() {super.viewDidLoad()// Enable cart and set an IDtracker.cart.set("1")// Declare first productlet p1 = tracker.products.add("1254[MF839FA]", category1: "2[Laptop]", category2: "20[Macbook Pro]")p1.quantity = 1p1.unitPriceTaxFree = 1839p1.unitPriceTaxIncluded = 2299products.append(p1)// Declare second productlet p2 = tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]")p2.quantity = 1p2.unitPriceTaxFree = 1199p2.unitPriceTaxIncluded = 1499products.append(p2)}override func viewWillAppear(animated: Bool) {// Send products viewstracker.products.sendViews()// Send screen hittracker.screens.add("Store").sendView()}@IBAction func addProductToCart(sender: UIButton) {// Add a previously declared product to the carttracker.cart.products.add(products[0])}override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {// Go to cart resume and send a screen hit with cart contentlet cartScreen = tracker.screens.add("Cart resume")// If isBasketScreen is not set to true, Cart info won't be added to Screen hitcartScreen.isBasketScreen = truecartScreen.sendView()}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#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 contentATScreen* cartScreen = [self.tracker.screens addWithName:@"Cart resume"];// If isBasketScreen is not set to true, Cart info won't be added to Screen hitcartScreen.isBasketScreen = YES;[cartScreen sendView];}@end
- Suppression d’un produit
12345@IBAction func removeProduct(sender: UIButton) {tracker.products.remove("1254[MF839FA]")}12345- (IBAction) removeProduct:(UIButton *)sender {[self.tracker.products removeWithId:@"1254[MF839FA]"];}
- Suppression de tous les produits
12345@IBAction func removeProducts(sender: UIButton) {tracker.products.removeAll()}12345- (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 |
Cet article vous a-t-il été utile ?
Oui
Non