Tagging your iOS App
The iOS SDK enables application developers to tag their application to enable measurement and reporting in Narratiive's dashboard.
Instructions are provided for implementing the SDK using X-Code.
Unique Browser (UUID)
The unique browser identifier used the
identifierForVendor Objective-C system call. The discussion on the value for this is provided below.
For details on how this identifier works, see Apple's official documentation.
Sessions and Duration
The sessions (visits) and duration are maintained by the SDK. Cookies are not required to track sessions and duration, however the methodology for calculating sessions and duration is written to mimic the cookie based metrics.
A page impression is recorded by the SDK every time the tracker methods are invoked. You can manually invoke impressions on screens using the track instance methods.
The user agent string is collected using the
1. Download the
libEmTracker library and header from the downloads section below.
2. Add both to your iOS application.
AppDelegate.m, in the appropriate place for your application entry point (e.g.
didFinishLanchingWithOptions), add the following calls to track the initial page view:
// Import statement, At the top of the file. #import "EmTracker.h" EmTracker *tracker = [EmTracker sharedInstance]; // replace "test" with an app name, allowed characters are a-z0-9- Spaces can not be included // replace "testiOS.com" with your domain name // replace "sdk-key-here" with the app key as provided by EM [tracker configure:@"test" tld:@"testiOS.com" sdkKey:@"sdk-key-here"]; // Actually track the default event and specify content // Use Empty string if content descriptor not required [tracker trackContent:@”contentDescip"];
Important: Please do not reverse the TLD. The domain labels should appear in their natural order and must be valid domain names.
If you need to change other settings, please refer to the
EmTracker.h header file for a reference of iOS-specific options (and tracker methods) and how to use them.
Using With Swift
To use the library within a Swift application, you need to import it using a bridging header and then import the header file (
EmTracker.h) within it.
How to create a Bridging Header
- In your Swift project, create a new file. When prompted, select Objective-C File.
- Give this file a temporary name, such as
- Click Finish, and Xcode will prompt you to create a Bridging Header. If it doesn't, you probably already have a Bridging Header in your project.
- Press Create Bridging Header to continue. Xcode will automatically create the new header file for you.
- Delete your
placeholder.mfiles from the project. You will notice a new file called
- Add the following import statement to the new Bridging Header: