#import
#import "EightdigitsClient.h"
@interface AppDelegate : UIResponder {
UINavigationController *navigationController;
EightdigitsClient *eightdigitsClient;
}
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) EightdigitsClient *eightdigitsClient;
@property (nonatomic, retain) UINavigationController *navigationController;
@end
self.eightdigitsClient = [[EightdigitsClient alloc]
initWithUrlPrefix:@"http://tr-api.8digits.com" trackingCode:@"code"];
[self.eightdigitsClient authWithUsername:@"username" password:@"password"];
[self.eightdigitsClient endVisit];
- (void)viewWillDisappear:(BOOL)animated {
[self.eightdigitsClient endScreenWithHitCode:self.hitCode];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.eightdigitsClient endScreenWithHitCode:self.hitCode];
}
[self.eightdigitsClient eventWithKey:@"UploadBusinessCard" value:@"1" hitCode:self.hitCode];
NSInteger score = [self.eightdigitsClient score];
NSArray *badges = [self.eightdigitsClient badges];
UIImage *image = [self.eightdigitsClient badgeImageForId:@"badgeId"];
this.eightDigitsClient = EightDigitsClient.createInstance(this, "", "");
this.eightDigitsClient = EightDigitsClient.getInstance();
this.eightDigitsClient.authWithUsername("", "");
int hitCode = this.eightDigitsClient.newVisit("< Title of Visit>", "");
int hitCode = this.eightDigitsClient.newScreen("< Screen Name>", "< Screen Path>");
this.eightDigitsClient.newEvent("", "", this.hitCode);
this.eightDigitsClient.setAsyncResultListener(new AsyncResultListener());
The tracking API will return plain text in Javascript Object Notation (JSON) format in response to any API call. The result object will always have a node called "result" which has a subnode called "code" which will be 0 in case of a successful operation, and any other value in case of an error. If there stands an error code in the code node, there will also be another subnode called "message" which will display a human readable error message which can be used for logging purposes.
authToken:It is the access token which is returned from the authentication process. This token should be stored in a temporary place at the client memory during the session.
trackingCode: Each application being tracked has its own unique tracking code. It is not a confidential information since it can't be used for any purpose without knowing the username & password combination. Tracking code will be provided by 8digits, and should be stored as a constant in your application.
visitorCode:Each visitor must have his/her own unique identifier. The tracking API doesn't provide a mechanism to create an identifier key. Each client has its own platform specific dependencies so the client has to provide its own. For the mobile platforms which are supported with a SDK, please check the SDK source codes.
sessionCode: Each visit from a visitor will be grouped using a session identifier called session code. The system will create reports and tracks a session behviour using this crucial information. The API lets you provide your own session code and if nor provided it will automatically assign one.
hitCode: Each major change in the UI during a session, is called a "new screen" and is symbolized by a "new hit". It is developers' responsibility to call if a change in the UI is a new screen or not. A minor change such as a button push, an alert window or a confirmation display shoudn't be treated as a new hit. Indeed, they are "events". A hit has its own hit code and each event occurred at a screen will provide this code to bind itself to a screen.
Each account has to provide a username and a password pair to identify itself to the system. If authenticated the system will return an auth token. The following requests will also send this token to identify itself.
The system has a powerful mechanism to protect itself from incoming threats. It will block the IP address from authentication after 5 unsuccessfull login attemps. There is also another mechanism that will block a username for 10 minutes after 3 unsuccessfull login attemps in 60 seconds.
{"result":{"code":0},"data":{"authToken":"[auth_token]"}}
Each time the application is launched a new session must be created. Similar to the web sessions, 8digits behaviour monitoring system also has a session code to group the individual steps as one.
To create a new session client has to provide a "tracking code" which is a hash string that is provided by us. Besides the tracking code the client also has to provide a visitor code. Visitor code is a unique identifier which will allow the 8digits system to track each individual visitor. Mobile platforms such as iOS and Android platforms can use their own platform specific APIs to create a unique device identifier or just use our SDKs which are supported and maintained by us.
For a mobile app, the splash screen is a nice place to create a new session. If a launching page is provided new visit API will also return a hit code for this page besides the session code.
The sessionCode and hitCode parameters are optional. If provided the system will use those values, but create its own if not.
{
"result":{"code":0},
"data": {
"sessionCode":"74164c40-0e1c-4d0b-98fa-5a02c7a03707",
"hitCode":"35103347"
}
}
For realistic "time on page" and "time on site" metrics, this API should be called just before the application closed. The 8digits system will work as expected without this API being called, but those two metrics which are quite useful to track visitors' loyalty will give significantly wrong results. It is because the system will wait for a timeout period to label a session as closed and it has no other way to know that the client is actually active or not.
If a visit(session) is closed, either with this method or automatically and a new hit with the same session code is received, a "reborn" routine will take place and the session will be re-awaken if it was never ended.
{"result":{"code":0}}
8digits monitoring platform utilizes the reverse IP address lookup mechanism to track visitor location. This facility is run automatically and most of the time accurate in a range of a few kilometers. Unfortunately, this assumption is not always true for mobile devices since mobile broadband providers use different approachs for assigning IP addresses to their subscribers. In such circumstances, if accuracy is important, mobile device can use its own GPS enabled location detection system and use this API to update its location.
Latitude and longitude variables are in decimal format.
{"result":{"code":0}}
Each major change in the UI during a session, is called a "new screen" and is symbolized by a "new hit". You can track how many people have displayed each screen, on which screen they left the application and how long did they stay on any of those screens.
If a screen is not ended it will remain as displayed. If a screen is about to be closed, it is developer's responsibility to call the hit/end API.
Each screen is symbolized by a hit code and this hit code will be used to end the page and send custom events that have occurred on this screen. If client wishes to use its own hitCode generation mechanism, it is also a supported feature. HitCode's must be unique during a session and can repeat itself amongst other sessions.
{"result":{"code":0},"data":{"hitCode":"3281359"}}
When finished with a screen, this API needs to be called in order to achieve accurate "time on page" metrics. Otherwise, the page will remain active until the timeout procedure is executed automatically. To end displaying a screen hitCode has to provided with this API call.
{"result":{"code":0}}
In an event driven approach, the client can generate an event anytime. An event can be a button push, a gesture a scroll or even a server side event that tells that a batch processing of a report has been finished. These events help creating your own business rule engine if used with 8digits' scnearios.
The events are extremely simple key and value pairs. Keys help classify and group these events, whilst values provide a numeric or non-numeric value for those key if it exists. Key field mustn't me empty but value field is optional. If a numeric value is provided 8digits' average of event values, sum of event values reports help you monitor what's going on in your application like you've never done before.
To illustrate, if you consider tracking a button push event, and that button adds an item to the shopping card, then the corresponding key might be: "AddToShopingCard" and the value can be 120.99, which is the price of the item being added to the shopping card.
If an event happens in a client application, then you can provide a hitCode to bind it to a screen and a session. In a server-side environment sessionCode and hitCode can be meaningless so they can just be omitted.
{"result":{"code":0}}
Badges are earned when a visitor finishes a scenario and an "assign badge" action was triggered. Those scenarios and actions are configured at the 8digits administration UI but they run automatically once they are stored. To get the list of the badge ids the visitor is carrying, this API call is used.
{"result":{"code":0},"data":{"badges":["4f0a9e450364c808e94bfd32"],"count":1}}
The badge id is used to display the badge's icon image using this API. This is a public API and an authentication token is not needed.
Displays the engagement score or the manuel score points depending on the score mechanism profile is using.
{"result":{"code":0},"data":{"score":30}}