Class
Permutive
@objc
public final class Permutive: NSObject
Relationships
Conforms To
NSObject
Properties
reactions
@objc
public var reactions: [String: [Int]]
The current enterd segments for each defined activation.
triggerProvider
@objc
public var triggerProvider: TriggerProviderProtocol?
An instance which provides TriggerAction instances. Used to watch for changes in segment states.
TriggerAction instances are held with weak references in the SDK.
Methods
googleCustomTargeting(adTargetable:)
@objc
public func googleCustomTargeting(adTargetable: AdTargetable? = nil) -> [String: String]?
Permutive custom targeting for GoogleMobileAds for use with ad requests.
This returns current Permutive segment information suitable for
custom targeting, e.g. GAMRequest.customTargeting.
Those information can be retrieved without a parameter but if the targeting relates to content being tracked by a PageTracker instance, it is recommended to pass that instance for best results.
Usage:
let banner = GAMBannerView(adSize: kGADAdSizeBanner)
let adRequest = GAMRequest()
adRequest.customTargeting = Permutive.shared.googleCustomTargeting(adTargetable: pageTracker)
banner.load(request)
Parameters
| Name | Type | Description |
|---|---|---|
| adTargetable | AdTargetable? |
An entity implementing the AdTargetingProtocol, currently a |
Returns
A dictionary that can be use with GAMRequest.customTargeting, see usage
setIdentity(alias:priority:expiry:)
@objc
public func setIdentity(alias: String, priority: UInt16, expiry: Date) throws
setIdentity(alias:priority:)
@objc
public func setIdentity(alias: String, priority: UInt16) throws
setIdentity(alias:expiry:)
@objc
public func setIdentity(alias: String, expiry: Date) throws
setIdentity(alias:)
@objc
public func setIdentity(alias: String) throws
setIdentities(aliases:)
@objc
public func setIdentities(aliases: [Alias]) throws
start(with:context:completion:)
@objc
public func start(with options: Options, context contextVals: Context? = nil, completion: @escaping (_ error: Error?) -> Void)
Starts the Permutive SDK with the given Options and optional Context. Once started the SDK is ready to track events.
A provided callback is executed on completion.
Parameters
| Name | Type | Description |
|---|---|---|
| options | Options |
The |
| contextVals | Context? |
A |
| completion | @escaping (_ error: Error?) -> Void |
A closure executed asynchronously. On completion without errors, the SDK is ready to accept event tracking requests. |
| error | An error, if any, encountered when starting the SDK. A nil error represents success. |
track(event:properties:)
@objc
public func track(event: String, properties: EventProperties? = nil) throws
Tracks an event.
Parameters
| Name | Type | Description |
|---|---|---|
| event | String |
The event name. E.g. |
| properties | EventProperties? |
An optional |
Throws
MessagedError.sdkInitialisation if tracking is attempted before the SDK has successfully started.
createPageTracker(properties:context:)
@objc
public func createPageTracker(properties: EventProperties? = nil, context: Context? = nil) throws -> NSObject & PageTrackerProtocol
Constructs a PageTracker. This allows tracking of events within the context of a single "page" or view. This allows tracking
the amount of a page viewed by a user as well as the time spent interacting with the page.
PageTracker Use
A PageTracker's expected use is to be associated with individual "page" or view. It is created with supplied Context information.
This context is included with all events tracked through the PageTracker instance for improved tracking of events.
Usage is expected to follow the sequence:
- A
PageTrackerinstance is created withContextfor a "page" or view. This can be done prior or on transition to a view. - On transition to a new view, the associated
PageTracker.start(properties:)is called. This tracks a "Pageview" event immediately. - Further information on page events are tracked through
PageTracker.track(event:, properties:)at appropriate times. - When about to leave a view,
PageTracker.stop()is called and the instance can be released if no longer needed. APageTrackerwill not be usable afterstop()is called.
Parameters
| Name | Type | Description |
|---|---|---|
| context | Context? |
An optional |
Throws
MessagedError.sdkInitialisation if tracking is attempted before the SDK has successfully started.
Returns
A instance meeting the PageTrackerProtocol. No strong references are kept by the SDK.
createVideoTracker(duration:properties:context:)
@objc
public func createVideoTracker(duration: TimeInterval = 0,
properties: EventProperties? = nil,
context: Context? = nil) throws -> NSObject & MediaTrackerProtocol
Constructs a video tracker. This allows tracking of interaction with video content.
Parameters
| Name | Type | Description |
|---|---|---|
| duration | TimeInterval |
A |
| properties | EventProperties? |
A |
| context | Context? |
An optional |
Throws
MessagedError.sdkInitialisation if tracking is attempted before the SDK has successfully started.
Returns
A instance meeting the MediaTrackerProtocol. No strong references are kept by the SDK.
reset()
@objc
public func reset() throws
Resets persisted data.
Throws
MessagedError.sdkInitialisation if tracking is attempted before the SDK has successfully started.