Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

4. Enabling Pyze Events & Custom Events

Pyze edited this page Jan 19, 2016 · 4 revisions

##Introduction Custom Events and are a critical part of deploying the Pyze Intelligence Platform. They provide deeper tracking of user activity and actions beyond the default metrics that are collected by Pyze. As users traverse different parts of your application, there are certain actions that are only specific to your application. For instance, tracking the number of pictures taken might be important for a photography app, the number of messages sent for a messaging app, or the number of levels played for a game. Tracking these events will provide you with a better understanding of usage patterns and are also used to create funnels to identify drop offs points and conversions of goals.

Pyze has already created over a dozen classes for tracking common events and use cases for applications. Click here for more details.

##Best Practices

When to use events It’s important to be thoughtful about which events should be tracked. Tracking too many events can be overwhelming so only critical events that provide insight into user behavior or actions that help separate different types of users should be tracked. Pyze provides a number of pre-defined event types that can help you get started and you can add your own custom events.

##Event Naming Event names should be as succinct as possible and describe the action that the user has just executed. For instance, events may be labeled as Video Viewed, Video Shared, Video Deleted.

##Using Attributes Attributes are an excellent want to capture key data points associated with an event. The attribute could be meta-data associated with an event such as the genre of the article for an “Article Read” event or how long it took the user to read the article.

##What Not to Track It’s important to only track events that will be useful for later analysis. It’s also better to send one event after an action completes rather than sending multiple events for start or end of an action. Attributes can be used to add metadata to an event. Its also not a good idea to call events for actions that are called recursively or in a loop which may result in large volumes of events being fired.

##Enabling Events

To track events in Android, ensure the following imports are included in the Activity where you will be adding events:

  import com.pyze.android.Pyze;
  import com.pyze.android.PyzeEvents;

Initialize Pyze Events in the onCreate method of your activity prior to sending any events. Failure to do this may cause your app not to work properly.

  Pyze.initializeEvents(getApplication());

To track Pyze Events in your app, check out the reference here. To track an custom event without attributes:

  PyzeEvents.trackEvent(“myEventName”);

To track an event with attributes, use Values to add attributes:

  PyzeEvents.trackEvent ("myEventName ", new Values()
	    .putValue("attribute1", "value1")
	    .putValue("attribute2", "value2")
		);

Clone this wiki locally