Tracking specific events

You can view reports that describe specific actions and events that occur in your application, such as button clicks, ad views, and errors. To track these types of events, you must invoke one of the following methods for each individual event when it occurs in your application.

Event

Method

Ad click

onAdClickEvent()

Ad impression

onAdImpressionEvent()

Application error

onApplicationError()

Button click

onButtonClick()

Screen view

onScreenView()

Conversion event

onConversionEvent()

Custom event

onCustomEvent()

Media event

onMediaEvent()

Product view

onProductView()

Search event

onSearchEvent()

Method: onAdClickEvent()

The onAdClickEvent() method collects information about individual ad click events and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about ad click events in the following reports:

  • In-App Ads
  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onAdClickEvent(String eventPath, String eventDesc, String eventType, 
        Hashtable customData, String adName)

Data collection parameters

When you invoke onAdClickEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia")

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom")

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.a_an

adName

Specifies the name of the ad

WT.a_ac

1

Indicates that an ad click occurred

WT.sys

"adclick"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking an ad click event

try
{
    WebtrendsDataCollector.getInstance().onAdClickEvent("/mainscreen/classifieds", 
        "Classifieds screen", "click", null, "car ad");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onAdImpressionEvent()

The onAdImpressionEvent() method collects information about ad impressions and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about ad impression events in the following reports:

  • In-App Ads
  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onAdImpressionEvent(String eventPath, String eventDesc, String eventType, 
        Hashtable customData, String[] adNames)

Data collection parameters

When you invoke onAdImpressionEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.a_an

adNames[]

Specifies an array of ad names.

WT.a_ai

1

Indicates that an ad impression occurred.

WT.sys

"adimpression"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking an ad impression event

String[] adNames = {"sports ad1", sports ad2", "sports ad3"};
try
{
    WebtrendsDataCollector.getInstance().onAdImpressionEvent("/newsapp/topstories", 
            "Headline screen", "ad view", null, adNames);
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onApplicationError()

The onApplicationError() method collects information about application errors and sends the information to the data collection server. To use this method, you must pass in the message that is associated with the error using a Hashtable object.

On the Analytics Service web portal, you can view data about errors in the following reports:

  • Events: App
  • Errors
  • Key Metrics

For a complete list of reports, and to see how parameters contribute to each report, see Reports and parameters.

Syntax

public void onApplicationError(String applicationName, Hashtable customData)

Arguments

Argument

Description

applicationName

Specifies the name of the application.

Sends the name of the application to the data collection server using the dcsuri parameter.

customData

Specifies a Hashtable object that contains custom data. This method requires that you pass in the WT.er parameter. You must set the value of WT.er to the status message of the exception that your application throws.

"error"

Specifies the type of system event.

Sends the name of the application to the data collection server using the WT.sys parameter.

For a list and descriptions of the parameters common to every event, see Common parameters.

Code sample: Tracking an application error event

try
{
    // code that the application is attempting to run
}
catch (Exception e)
{
    Hashtable customParams = new Hashtable();
    customParams.put("WT.er", e.getMessage());    
 
    try
    {
        WebtrendsDataCollector.getInstance().onApplicationError("Analytics Demo", customParams);
    }
    catch (IllegalWebtrendsParameterValueException err)
    {
        WebtrendsDataCollector.getLog().e(err.getMessage());
    }
}
Back To Top

Method: onButtonClick()

The onButtonClick() method collects information about button clicks and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about button click events in the following reports:

  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Synatx

public void onButtonClick(String eventPath, String eventDesc, String eventType, 
        Hashtable customData)

Data collection parameters

When you invoke onButtonClick(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. Sending custom data is not supported by this method.

WT.sys

"click"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a button click event

try
{
    WebtrendsDataCollector.getInstance().onButtonClick("/chatapp/newuser", 
            "Signup screen", "sign up", null);
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onScreenView()

The onScreenView() method collects information about content view events and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about content view events in the following reports:

  • Events: App
  • Events
  • Media: Titles
  • Media: Types
  • Key Metrics

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onScreenView(String eventPath, String eventDesc, String eventType,
         Hashtable customData, String contentGroup)

Data collection parameters

When you invoke onScreenViewEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where a screen is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.cg_n

contentGroup

Specifies a category name for the content (for example, "sports" or "music").

WT.sys

"screen"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a screen view event

try
{
    WebtrendsDataCollector.getInstance().onScreenView("/eBooksApp/newbook/details", 
            "Book viewer screen", "book view", null, "fiction");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onConversionEvent()

The onConversionEvent() method collects information about conversion events and sends the information to the data collection server. This method does not support the customData, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about conversion events in the following reports:

  • Events:Conversion
  • Events: App
  • Events
  • Key Metrics

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onConversionEvent(String eventPath, String eventDesc, String eventType, 
        Hashtable customData, String contentGroup, String conversionName)

Data collection parameters

When you invoke onConversionEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.cg_n

contentGroup

Specifies a category name for the content (for example, "sports" or "music").

WT.conv

conversionName

Specifies a name for the conversion type.

WT.si_cs

1

Indicates that the conversion step is successful.

WT.sys

"conversion"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a conversion event

try
{
    WebtrendsDataCollector.getInstance().onConversionEvent("/musicapp/preview", 
            "Upgrade version screen", "upgrade", null, "music", "full version");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onCustomEvent()

The onCustomEvent() method collects information about custom events and sends the information to the data collection server.

In the web portal for the Analytics Service, you can view data about custom events in the following reports:

  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onCustomEvent(String eventPath, String eventDesc, 
        Hashtable customData)

Data collection parameters

When you invoke onCustomEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia")

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs

WT.ev

customData

Specifies a Hashtable object that contains custom data. This method requires that you pass in the WT.ev parameter. You must set the value of WT.er to the type of event that occurs (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

WT.sys

"custom"

Specifies the type of system event

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a custom event

Hashtable customParams = new Hashtable();
customParams.put("WT.ev", "Level cleared");

try
{
    WebtrendsDataCollector.getInstance().onCustomEvent("ActionGame/main", "Level 3", 
            customParams);
}
catch (IllegalWebtrendsParameterValueException e)
{
    WebtrendsDataCollector.getLog().e(e.getMessage());
}
Back To Top

Method: onMediaEvent()

The onMediaEvent() method collects information about media events and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about media events in the following reports:

  • Media: Titles
  • Media: Types
  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onMediaEvent(String eventPath, String eventDescr, String eventType, 
        Hashtable customData, String contentGroup, String mediaName, 
        String mediaType, String mediaEventType)

Data collection parameters

When you invoke onMediaEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.cg_n

contentGroup

Specifies a category name for the content (for example, "sports" or "music").

WT.clip_n

mediaName

Specifies the name of the piece of media.

WT.clip_t

mediaType

Specifies the type of media (for example, "music" or "video").

WT.clip_ev

mediaEventType

Specifies the status of the media event. Acceptable values are "p" (played), "25" (25% completed), "50" (50% completed), "75" (75% completed, and "f" (finished).

WT.sys

"media"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a media event

try
{
    WebtrendsDataCollector.getInstance().onMediaEvent("/MyMusic/catalog", 
            "Media player screen", "play song", null, "Music", "mp3", "75");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onProductView()

The onProductView() method collects information about individual product view events and sends the information to the data collection server.

In the web portal for the Analytics Service, you can view data about product view events in the following reports:

  • Products
  • Product: Types
  • Events: App
  • Events
  • Categories
  • Key Metrics

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onProductView(String eventPath, String eventDesc, String eventType, 
        Hashtable customData, String contentGroup, String productId, 
        String productSku)

Data collection parameters

When you invoke onProductView(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

WT.tx_e, WT.tx_u

customData

Specifies a Hashtable object that contains custom data. This method requires that you pass in the WT.tx_e and WT.tx_u parameters. You must set the value of WT.tx_e to "v", and the value of WT.tx_u to the number of product views.

WT.cg_n

contentGroup

Specifies a category name for the content (for example, "sports" or "music").

WT.pn_id

productId

Specifies the ID for the product (optional).

WT.pn_sku

productSku

Specifies the SKU for the product.

WT.sys

"product"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a product view event

Hashtable customParams = new Hashtable();
customParams.put("WT.tx_e", "v");
customParams.put("WT.tx_u", "4");

try
{
    WebtrendsDataCollector.getInstance().onProductView("/eBooksApp/newbook/details", 
            "Details Screen", "eBook view", customParams, "Sports", "12345", "abc123");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top

Method: onSearchEvent()

The onSearchEvent() method collects information about user searches and sends the information to the data collection server. This method does not support the customData argument, so you must pass in null as the value when you invoke the method.

In the web portal for the Analytics Service, you can view data about search events in the following reports:

  • In-App Searches
  • Events: App
  • Events

For a complete list and descriptions of reports, see Reports and parameters.

Syntax

public void onSearchEvent(String eventPath, String eventDesc, String eventType, 
        Hashtable customData, String searchPhrase, String searchResult)

Data collection parameters

When you invoke onSearchEvent(), the following parameters are sent to the data collection server to populate reports.

Parameter

Value

Description

dcsuri

eventPath

Specifies the hierarchical location of where an object or content is located in an application (for example, "mainscreen/optionscreen/samplemedia").

WT.ti, WT.pi

eventDesc

Specifies the name of the screen where the event occurs.

WT.ev

eventType

Specifies the event type (for example, you can track general events such as "click" or "view", or you can track more specific events such as "horizontal swipe" or "zoom").

null

customData

Specifies a Hashtable object that contains custom data. This method does not support sending custom data.

WT.oss

searchPhrase

Specifies a search phrase used in the application.

WT.oss_r

searchResult

Specifies a String that contains an integer that represents the number of search results returned.

WT.sys

"search"

Specifies the type of system event.

For a list of parameters common to all events, see the parameter reference.

Code sample: Tracking a search event

try
{
    WebtrendsDataCollector.getInstance().onSearchEvent("/GPSapp/newlocation", 
            "Navigation screen", "search", null, "Waterloo", "1");
}
catch (IllegalWebtrendsParameterValueException err)
{
    WebtrendsDataCollector.getLog().e(err.getMessage());
}
Back To Top
Next topic: Types of reports

Was this information helpful? Send us your comments.