[L3881] Add custom tracking of States, Actions, and Locations. - Adobe-Marketing-Cloud/aml-summit-lab GitHub Wiki
Objective
In this section, we are going to add some Analytics tracking calls to send information about user activities. Specifically, we'll write some code that makes a "trackAction" analytics call reporting the tip amount the end user decides to pay.
Then, in the next section, we'll use this tip amount to define some rules and take actions based on this data.
Setup
-
Navigate to TipDriverViewController.m located within the ViewControllers folder.
Implementation Steps
- Import the ADBMobile.h header file
- Go to line #20.
- Delete the "//" in front of #import "ADBMobile.h". It should look like as:
#import "ADBMobile.h"
- Add tracking of the Tip Driver view
- The trackState method will record that the user visited the "Tip Driver" view
- Go To Line #29 and delete "//".
- The trackLocation method will record that the user's location at the time they viewed the "Tip Driver" view
- Go To Line #34 and delete "//".
It should look like this:
- (void) viewWillAppear:(BOOL)animated {
/*
* 1. track the user viewing this page
*/
[ADBMobile trackState:@"Tip Driver" data:nil];
/*
* 2. track the location of the user after they arrive
*/
[ADBMobile trackLocation:_user.trip.destination.location data:@{@"summit.year":@"2017"}];
// update the labels in our UI
[self updateTextForLabels];
// change the color of our segment control when a segment is selected
[self setupTipControl];
}
- Add tracking to report the tip amount by a user
- The trackAction method will record what the user tip amount.
- Go to line #52.
- Delete the "//"
- It should look as follows:
- (IBAction) setTipAmount:(id)sender {
UISegmentedControl *segment = (UISegmentedControl *)sender;
NSString *tipAmount = [segment titleForSegmentAtIndex:segment.selectedSegmentIndex];
/* Adobe Analytics
*
* 1. track the tip amount selected by the user
*/
[ADBMobile trackAction:@"SetTipAmount" data:@{@"tipAmount":tipAmount}];
}
Next Steps
PREVIOUS: Enable the collection of Lifecycle data