Overview

Events are intended to record various actions a user performs in the application.
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 its values.

Once properly collected, this data can be used to:

  • trigger certain In-App Messages to be displayed;
  • build a segment of users who are eligible to receive an In-App;
  • get insights about user flow in the app, usage metrics, and other statistical data.

Prerequisites

Event data is valuable only if it's submitted properly. Therefore, we strongly recommend to follow 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. I.e., use "Subscribed" event with proper attribution rather than separate "SubscribedToSports", "SubscribedToPolitics", "SubscribedToTechnology" events.

Attributes

All details describing an event are provided with its attributes. All events sent by your application must be created in Pushwoosh first with the set of attributes and their types, otherwise, Pushwoosh will not recognise them. All 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. through Facebook, Google+, Twitter or email), internet connection type (wifi, cellular, unknown), and whether it was successful or not (true or false values) with just one Login event by specifying the following attributes:

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 to build a segment of users who are eligible of receiving a certain In-App Message.

Integration

iOS

When an interesting event occurs in your iOS application, use the following instructions to send this event to Pushwoosh.

Call the postEvent to send an event to Pushwoosh:

PWInAppManager.shared().postEvent("Login", withAttributes: nil)
[[PWInAppManager sharedManager] postEvent:@"Login" withAttributes:@{}];

In order to add details about the event you should use attributes describing it as follows:

NSDictionary *attributes = @{ @"AttributeString" : @"someString",
								  @"AttributeInt" : @(42),
								  @"AttributeList" : @[ @(123), @(456), @"someString" ],
								  @"AttributeBool" : @YES,
								  @"AttributeDate" : [NSDate date] };

[[PWInAppManager sharedManager] postEvent:@"eventName" withAttributes:attributes];
        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 interesting event occurs in your Android application, use the following instructions to send this event to Pushwoosh.

Call the postEvent to send an event to Pushwoosh:

InAppFacade.postEvent(this, “eventName”, new HashMap<String, Object>());

In order to add details about the event you should use attributes describing it:

HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put("AttributeString", "someString");
attributes.put("AttributeInt", 42);

ArrayList<Integer> arrayAttribute = new ArrayList<Integer>();
arrayAttribute.add(1);
arrayAttribute.add(2);
arrayAttribute.add(3);
attributes.put("AttributeList", arrayAttribute);

attributes.put("AttributeBool", Boolean.TRUE);
attributes.put("AttributeNull", null);
attributes.put("AttributeDate", new Date());

InAppFacade.postEvent(this, “eventName”, attributes);

In-App Messages

You can also send events from In-App Javascript.

Events