-
You need CocoaPods installed.
-
Create a file called
Podfile
in your project and add the following line:pod 'liferay-analytics-ios'
-
Run
$ pod install
. -
This will download the latest version of the SDK and create a .xcworkspace file, use that file to open your project in Xcode.
You should initialize the library providing your analytics key, it is recommended to add the command on applicationDidFinishLaunching
method in your AppDelegate
. If you don't initialize the library, you will get an error .analyticsNotInitialized
or .analyticsAlreadyInitialized
if the library is already initialized.
Parameters:
- analyticsKey: String (required)
- flushInterval: Int (optional)
try Analytics.configure(analyticsKey: "YOUR_ANALYTICS_KEY", flushInterval: 50)
It is recomended to call when the user is logged in, necessary to bind the next events for this user. The name parameter is optional.
Parameters:
- email: String (required)
- name: String (optional)
Analytics.setIdentity(email: "user email", name: "user name")
It is recomended to call when the user is logged out, necessary to unbind the next events of the previous user.
Analytics.clearSession()
Method to send any custom event.
Parameters:
- eventId: String (required)
- applicationId: String (required)
- properties: [String: String] (optional). For additional properties
Analytics.send(
eventId: "PageView",
applicationId: "MYSAMPLE",
properties: ["custom1": "value 1",
"custom2": "value 2"])
-
You need CocoaPods installed.
-
Create a file called
Podfile
in your project and add the following line:pod 'liferay-analytics-forms-ios'
-
Run
$ pod install
. -
This will download the latest version of the SDK and create a .xcworkspace file, use that file to open your project in Xcode.
It is a struct to contextualize forms events.
Parameters:
- formId: String (required)
- formTitle: String (optional)
let formAttributes = FormAttributes(formId: "10", formTitle: "People")
Method to send a form viewed event.
Parameters:
- attributes: FormAttributes (required)
Forms.formViewed(attributes: formAttributes)
Method to send a form submit event.
Parameters:
- attributes: FormAttributes (required)
Forms.formSubmitted(attributes: formAttributes)
It is a struct to contextualize field events.
Parameters:
- name: String (required)
- title: String (optional)
- formAttributes: FormAttributes (required)
let fieldNameAttributes = FieldAttributes(name: "nameField", title: "Name", formAttributes: formAttributes)
Method to track all events from the Field, like (Focus and Blur).
Parameters:
- field: (UITextField || UITextView) (required)
- fieldAttributes: FieldAttributes (required)
Forms.trackField(field: field, fieldAttributes: fieldAttributes)