WTDataCollector Class Reference

Inherits from NSObject
Declared in WTDataCollector.h

Overview

WTDataCollector is the central class provided by WebtrendsSDK. Its central purpose is to log and send events to the Webtrends collection servers. It’s primarily accessed through its sharedCollector singleton. It should not be manually initialized.

Singleton

+ sharedCollector

WTDataCollector should not be initialized manually, but should instead be messaged through this singleton instance.

+ (instancetype)sharedCollector

Return Value

The WTDataCollector singleton.

Declared In

WTDataCollector.h

Triggering Events

– triggerEventForApplication:startWithCustomParams:

Creates and schedules an event for the application starting. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForApplication:(NSString *)appName startWithCustomParams:(NSDictionary *)customParams

Parameters

appName

Specifies the name of your application

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForApplication:terminateWithCustomParams:

Creates and schedules an event for the application terminating. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForApplication:(NSString *)appName terminateWithCustomParams:(NSDictionary *)customParams

Parameters

appName

Specifies the name of your application

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForApplication:didEnterBackgroundWithCustomParams:

Creates and schedules an event for the application entering the background. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForApplication:(NSString *)appName didEnterBackgroundWithCustomParams:(NSDictionary *)customParams

Parameters

appName

Specifies the name of your application

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForApplication:willEnterForegroundWithCustomParams:

Creates and schedules an event for the application entering the foreground. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForApplication:(NSString *)appName willEnterForegroundWithCustomParams:(NSDictionary *)customParams

Parameters

appName

Specifies the name of your application

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForApplication:withErrorMessage:customParams:

Creates and schedules an event for the application errors.

- (NSDictionary *)triggerEventForApplication:(NSString *)appName withErrorMessage:(NSString *)errorMessage customParams:(NSDictionary *)customParams

Parameters

appName

Specifies the name of your application

errorMessage

Specifies the error message associated with the error.

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForViewDidAppear:withCustomParams:

Creates and schedules an event for a view controller appearing. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForViewDidAppear:(NSString *)controllerTitle withCustomParams:(NSDictionary *)customParams

Parameters

controllerTitle

Specifies the title of the view controller

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForViewDidDisappear:withCustomParams:

Creates and schedules an event for a view controller disappearing. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForViewDidDisappear:(NSString *)controllerTitle withCustomParams:(NSDictionary *)customParams

Parameters

controllerTitle

Specifies the title of the view controller

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForNotification:withCustomParams:

Creates and schedules an event for a notification firing. This can be used for both local and remote notifications. If automatic events are enabled, an event of this type will automatically be logged, if not, it can be manually logged with this method.

- (NSDictionary *)triggerEventForNotification:(NSString *)notificationMessage withCustomParams:(NSDictionary *)customParams

Parameters

notificationMessage

Specifies the message presented in the notification

customParams

Specifies any user-defined data to be included with the event. Must be a dictionary with strings as both the key and the value. For example, a user id string to tie events to a given user.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForAdClickName:eventMeta:

Creates and schedules an event for an advertisement being tapped.

- (NSDictionary *)triggerEventForAdClickName:(NSString *)adName eventMeta:(WTEventMeta *)meta

Parameters

adName

Specifies the name of the advertisement.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForAdImpressionNames:eventMeta:

Creates and schedules an event for an ad impression

- (NSDictionary *)triggerEventForAdImpressionNames:(NSArray *)adNames eventMeta:(WTEventMeta *)meta

Parameters

adNames

Specifies an array of string ad names that were shown.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForSearchPhrase:searchResult:eventMeta:

Creates and schedules an event for a search event

- (NSDictionary *)triggerEventForSearchPhrase:(NSString *)searchPhrase searchResult:(NSString *)searchResult eventMeta:(WTEventMeta *)meta

Parameters

searchPhrase

Specifies the string the user searched for.

searchResult

Specifies the string of the search result.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForContentView:contentGroup:

Creates and schedules an event for a content view such as when an article or image is viewed.

- (NSDictionary *)triggerEventForContentView:(WTEventMeta *)meta contentGroup:(NSString *)contentGroup

Parameters

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

contentGroup

Specifies a group of related application views.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForScreenView:contentGroup:

Creates and schedules an event for a screen view such as when a screen, article, or image is viewed.

- (NSDictionary *)triggerEventForScreenView:(WTEventMeta *)meta contentGroup:(NSString *)contentGroup

Parameters

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

contentGroup

Specifies a group of related application views.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForProductId:productSku:contentGroup:eventMeta:

Creates and schedules an event for a product view

- (NSDictionary *)triggerEventForProductId:(NSString *)productId productSku:(NSString *)productSku contentGroup:(NSString *)contentGroup eventMeta:(WTEventMeta *)meta

Parameters

productId

Specifies a product identifier.

productSku

Specifies a unique product stock-keeping unit (SKU) number.

contentGroup

Specifies a group of related application views.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForEventMedia:contentGroup:eventMeta:

Creates and schedules an event for a media view

- (NSDictionary *)triggerEventForEventMedia:(WTEventMedia *)media contentGroup:(NSString *)contentGroup eventMeta:(WTEventMeta *)meta

Parameters

media

Specifies a WTEventMedia object that stores parameter types associated with media events.

contentGroup

Specifies a group of related application views.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForConversion:contentGroup:eventMeta:

Creates and schedules an event for a conversion, such as when a purchase or registration, occurs.

- (NSDictionary *)triggerEventForConversion:(NSString *)conversionName contentGroup:(NSString *)contentGroup eventMeta:(WTEventMeta *)meta

Parameters

conversionName

Specifies the name used to identify a customer conversion.

contentGroup

Specifies a group of related application views.

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

See Also

Declared In

WTDataCollector.h

– triggerEventForAction:

Creates and schedules an event for an arbitrary action, such as a button tap

- (NSDictionary *)triggerEventForAction:(WTEventMeta *)meta

Parameters

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– triggerEventForCustomEvent:

Creates and schedules a custom event, used to encapsulate any event not covered by the convenience event types.

- (NSDictionary *)triggerEventForCustomEvent:(WTEventMeta *)meta

Parameters

meta

Specifies a WTEventMeta object that stores common parameter types attached to this event.

Return Value

A dictionary of the event that is created

Declared In

WTDataCollector.h

– saveWatchEvent:

Read a watchkit sdk event in, and synchronously write it to the store

- (BOOL)saveWatchEvent:(NSDictionary *)dictionary

Parameters

dictionary

The dictionary potentially containing a watchkit event

Return Value

YES if the dictionary is a Webtrends Event, NO if not

Declared In

WTDataCollector.h

General Methods

– appendSessionParamsToUrl:

This method is used for maintaining a session within an embedded UIWebView. Before loading a new webview, use this method to append the current session information onto the URL you wish to load.

- (NSURL *)appendSessionParamsToUrl:(NSURL *)url

Parameters

url

The url you wish to append

Return Value

The final URL to load in your webview, with the current session information appended as a query string.

Declared In

WTDataCollector.h

– openURL:

Opens the given URL in Safari after appending the current session information.

- (void)openURL:(NSURL *)url

Parameters

url

The url to open.

Declared In

WTDataCollector.h

– scheduleSend

Adds a single send operation onto the Data Collector’s internal queue. Each send operation sends a batch of events to the collector’s servers. Operations are executed in the order they are received.

- (void)scheduleSend

Declared In

WTDataCollector.h

– scheduleSendAll

Adds a send all operation onto the Data Collector’s internal queue. This operation sends all events currently in the event store to the collector’s servers. Operations are executed in the order they are received.

- (void)scheduleSendAll

Declared In

WTDataCollector.h

– pause

By default, the Data Collector will periodically send events to its data collection servers based on your configuration settings. This method temporarily disables that periodic sending. You can still manually send events using -scheduleSend and -scheduleSendAll while periodic sending is paused.

- (void)pause

Declared In

WTDataCollector.h

– resume

By default, the Data Collector will periodically send events to its data collection servers based on your configuration settings. This method resumes that periodic sending, and also immediately schedules a send event.

- (void)resume

Declared In

WTDataCollector.h

– valueForConfigKey:

Returns the value for a given Webtrends config key (or a user-defined key). See the Advanced Configuration Guide for a list of first party keys.

- (id)valueForConfigKey:(NSString *)key

Parameters

key

The key for the value you want returned

Return Value

The value, as an id. Depending on the key supplied, this may be a NSNumber, an NSString, or an NSURL*

Declared In

WTDataCollector.h

– setValue:forConfigKey:

Sets a new value for a given Webtrends config key (or a user-defined key). See the Advanced Configuration Guide for a list of first party keys. This value will only be set in memory, use setValue:forConfigKey:persists: to store values permanently. Both the key and value must be NSString*

- (void)setValue:(NSString *)value forConfigKey:(NSString *)key

Parameters

value

The value to store, as an NSString*

key

The key for the value to be associated with

Declared In

WTDataCollector.h

– setValue:forConfigKey:persists:

Sets a new value for a given Webtrends config key (or a user-defined key). See the Advanced Configuration Guide for a list of first party keys. Both the key and value must be NSString*

- (void)setValue:(NSString *)value forConfigKey:(NSString *)key persists:(BOOL)persists

Parameters

value

The value to store, as an NSString*

key

The key for the value to be associated with

persists

Whether or not the value will be persisted to disk

Declared In

WTDataCollector.h

– isEnabled

This method returns whether or not data collection is currently enabled. If disabled, no events will be logged, and no events currently in the event store will be sent to the data collector’s servers.

- (BOOL)isEnabled

Return Value

Whether or not data collection is currently enabled.

Declared In

WTDataCollector.h

– eventStoreCount

The count of events currently stored locally.

- (NSInteger)eventStoreCount

Return Value

The count of events currently stored locally.

Declared In

WTDataCollector.h

– setValue:forRCSMetaKey:

Sets a new value for the given Remote Configuration Server meta key. Use this if you want to set Remote Configuration rules against arbitrary user-defined keys.

- (void)setValue:(NSString *)value forRCSMetaKey:(NSString *)key

Parameters

value

The value to store, as an NSString*

key

The key for the value to be associated with

Declared In

WTDataCollector.h