Gestures

  • iOS
  • watchOS
  • tvOS
 

Get off to a good start

Once your tag is initialised, you can start tagging gestures made by your users.

In the case of a Swift project, be sure to import the Tracker (or tvOSTracker/watchOSTracker if your target is a tvOS or watchOS device) module in your ViewController. In the case of an Objective-C project, be sure to import the headers or Tracker-Swift.h (or Tracker-Swift.h with Cocoapods).

Declare a Tracker type variable in your ViewController.

import UIKit
import Tracker

class ViewController: UIViewController {
    let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
#import "Tracker/Tracker-Swift.h"

@interface ViewController ()
@property (nonatomic, strong) Tracker *tracker;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tracker = [ATInternet sharedInstance].defaultTracker;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

Tagging

To tag a gesture, the tracker exposes a gestures property that offers an add method.

By default, this method adds “touch”-type tagging. You can edit the event type via the action property of the Gesture object, returned by the add method.

The different actions are the following:

  • Touch: Sends a hit indicating that a “touch” has occurred
  • Navigate: Sends a hit indicating that a navigational item was touched
  • Download: Sends a hit indicating that a download was triggered
  • Exit: Sends a hit indicating that the user changed the display or closed the application
  • Search: Sends a hit indicating that the user “clicked” on a search result item

To send the defined information, you must manually call the method sendNavigation, sendExit, sendDownload, sendTouch or sendSearch of your Gesture object, or call the Tracker’s dispatch method.

Please note, calling the methods sendNavigation, sendExit, sendDownload, sendTouch and sendSearch modifies the action property of the Gesture object.

 

Tagging examples

  1. Tagging a navigational button:
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){
        tracker.gestures.add("Go to product detail").sendNavigation()
    }
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        [[self.tracker.gestures add:@"Go to product detail"] sendNavigation];
    }
  2. Tagging a navigational button with chapters:
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){
        tracker.gestures.add("Go to product detail", chapter1: "Products", chapter2: "Cart").sendNavigation()
    }
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        [[self.tracker.gestures add:@"Go to product detail" chapter1:@"Products" chapter2:@"Cart"] sendNavigation];
    }
  3. Tagging a button touch:
    @IBAction func sayHelloHAL(sender: UIButton) {
        let sayHello = tracker.gestures.add("Say Hello HAL")
        sayHello.level2 = 1
        sayHello.sendTouch()
    }
    - (IBAction)sayHelloHAL:(UIButton *)sender {
        Gesture *sayHello = [self.tracker.gestures add:@"Say Hello HAL"];
        sayHello.level2 = 1;
        [sayHello sendTouch];
    }
  4. Tagging a touch with a name defined via a CustomObject (the name will be treated via DataManager)

    @IBAction func sayHelloHAL(sender: UIButton) {
        let touch = tracker.gestures.add()
        touch.customObjects.add(["touchName": "Say Hello HAL"])
        touch.sendTouch()
    }
    - (IBAction)sayHelloHAL:(UIButton *)sender {
        Gesture *gesture = [[tracker gestures] add:@"Click"];
        [gesture.customObjects addDictionary:@{@"touchName": @"Say Hello HAL"}];
        [gesture sendTouch];
    }
 

Gesture class

 

Properties

NameTypeDefault valueDescription
nameStringEmpty stringGets or sets the gesture name
chapter1String?nilGets or sets the first chapter
chapter2String?nilGets or sets the second chapter
chapter3String?nilGets or sets the third chapter
actionEnumAction.TouchGets or sets the action type
level2Int?nilGets or sets the level 2 ID
customObjectsCustomObjectsCustomObjectsGets or sets the customObject
 

Methods

NameReturn typeDescription
sendTouchvoidSends a hit indicating that a “clickable” element was touched
sendNavigationvoidSends a hit indicating that a navigational item was touched
sendDownloadvoidSends a hit indicating that a download was triggered
sendExitvoidSends a hit indicating that the user changed the display or closed the application
sendSearchvoidSends a hit indicating that the user “clicked” on a search result item
 

Was this post helpful?

Last update: 22/07/2019