Events

This guide addresses using Events to track and understand user behavior

Overview

Events are intended to record various actions a user performs in the app. Unlike Tags that are used to store flat data (such as country, device model, or installation data), event data is stored historically and can be treated as a history of user behavior rather than a set of information about the device. All the contextual information about the event can be passed as a set of attributes and their values.

Once properly collected, this data can be used to:

  • trigger behavior-based messages;

  • build segments of users who perform a specific action in the app;

  • get insights about user flow, usage metrics, and other statistical data.

Implementation

1. Create events in Pushwoosh Control Panel

All events sent by your app must be created in Pushwoosh first with the set of attributes and their types; otherwise, Pushwoosh will not recognize them.

To create an event, go to the Events section of your Control Panel and press the Add event button. Enter the name and description and add the attributes if needed.

Event data is valuable only if it's submitted properly. Therefore, we strongly recommend following the simple guidelines below:

  • Try to name events as short as possible;

  • Name events after actions a user performs in the app - "LoggedIn", "SignedOut", "Subscribed", etc.;

  • Keep in mind that event names are case-sensitive;

  • Merge events that describe a single action into a single event. For example, use "Subscribed" event with proper attribution rather than separate "SubscribedToSports", "SubscribedToPolitics", "SubscribedToTechnology" events.

2. Set attributes

All details describing an event are provided with its attributes. Attributes are key/value pairs and can be of 5 different types: integer, string, list, date, and boolean. For example, you can track user logins and collect login credentials (e.g., logged in with Facebook, Google, Twitter, or email), internet connection type (wifi, cellular, unknown), and whether it was successful or not (true or false values) with a single Login event by specifying its attributes as follows:

attribute

type

value

type

string

facebook, google, twitter, email

connection

string

wifi, cellular, unknown

success

boolean

true, false

This event will be recorded in Pushwoosh with attribute values and a timestamp, so later it can be used for building segments, targeting messages, and collecting stats.

You can add up to 50 attributes to an event, with the payload (content) of each attribute limited to 10 KB.

3. Call /postEvent API

When an event you’d like to track occurs in your app, call the /postEvent API to send this event to Pushwoosh.

iOS

Call the postEvent to send an event to Pushwoosh:

PWInAppManager.shared().postEvent("eventName", withAttributes: nil)

To add details about the event (ref. to Attributes), use the attributes param as follows:

let attributes: [String : Any] = ["AttributedString" : "someString",
                                  "AttributeInt" : 42,
                                  "AttributeList" : [123, 456, "someString"],
                                  "AttributeBool" : true,
                                  "AttributeDate" : NSDate()]
        
PWInAppManager.shared().postEvent("eventName", withAttributes: attributes)

Android

When an event occurs in your Android app, use the following instructions to send this event to Pushwoosh.

Call the postEvent to send an event to Pushwoosh:

PushwooshInApp.getInstance().postEvent("eventName");

To add details about the event (ref. to Attributes), use the attributes param as follows:

TagsBundle attributes = new TagsBundle.Builder()
				.putInt("AttributeInt", 17)
				.putString("AttributeString", "str")
				.putDate("AttributeDate", new Date())
				.putBoolean("AttributeBool", true)
				.putList("AttributeList", Arrays.asList("item1", "item2", "item3"))
				.build();

PushwooshInApp.getInstance().postEvent("eventName", attributes);

You can also send events from In-App Javascript.

Last updated