Internal search engine

  • iOS
  • watchOS
  • tvOS
 

Foreword

AT Internet’s SDK allows you to tag your application’s internal search engine. By doing so, you can see which keywords were entered, as well as the results screen number, and the position of the item selected by the user.

 

Get off to a good start

Once your tag is initialised, you can add the search information to your screen or gesture hit.

In the case of a Swift project, be sure to import the SmartTracker module in your ViewController. In the case of an Objective-C project, be sure to import the header SmartTracker-Swift.h.

 

Tagging

The Screen and Gesture objects make an internalSearch property available.

 

 

Tagging example

Tagging a search (the user is redirected toward a screen containing the results)

Here, parameters are passed as parameters during the selection of an item on the search screen

  1. Search screen tagging

    import UIKit
    import Tracker
    
    class SearchViewController: UIViewController {
        
        let tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Do any additional setup after loading the view.
        }
        
        override func viewWillAppear(_ animated: Bool) {
            let screen = tracker.screens.add("Search View")
            screen.internalSearch = InternalSearch(keyword: "Keyword", resultScreenNumber: 1)
            screen.sendView()
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    }
    
    // SearchViewController.m
    
    #import "SearchViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface SearchViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation SearchResultViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        Screen *screen = [self.tracker.screens add:@"Search View"];
        screen.internalSearch = [[InternalSearch alloc] initWithKeyword: @"Keyword" resultScreenNumber:1];
        [screen sendView];
    }
    
    @end
  2. Result clic tagging

    // SearchViewController.swift
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let gesture = tracker.gestures.add("SearchLabel")
        gesture.internalSearch = InternalSearch(keyword: "keywordLabel", resultScreenNumber: 1)
        gesture.internalSearch?.resultPosition = 5
        gesture.sendSearch()
    }
    // SearchViewController.m
    
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
         Gesture *gesture = [self.tracker.gestures add:@"SearchLabel"];
         InternalSearch *internalSearch = [[InternalSearch alloc] initWithKeyword: @"Keyword" resultScreenNumber:1];
         internalSearch.resultPosition = 5;
         gesture.internalSearch = internalSearch;
         [gesture sendSearch];
    }
 

InternalSearch class

 

Properties

NameTypeDefault valueDescription
keywordStringEmpty stringGets or sets keywords entered during the search
resultScreenNumberInt1Gets or sets the screen number containing the item on which the user clicked
resultPositionInt?nilGets or sets the position of the item on which the user clicked
 

Was this post helpful?

Last update: 03/03/2017