# How to set up events

**Events** are used to track various actions performed by users in the app. The data from events is stored historically, creating a timeline of user behavior. 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;
* modify the user communication flow within a Customer Journey based on their behavior;
* build segments of users who perform a specific action in the app;
* get insights about user flow, usage metrics, and other statistical data.

## Types of events

There are two types of events in Pushwoosh:
- Default events 
- Custom events 

### Default events
Default Events are basic interactions that users perform in apps or websites regardless of their industry or functionality. These key user actions form the core of customer communication and can be leveraged for any product and customer at any stage of the customer lifecycle. 
Default Events are available out of the box with the latest SDK versions and do not require any additional setup, except for [PW_InAppPurchase](/product/audience-data-and-segmentation/events/default-events#pw_inapppurchase). 

Learn more about [Default Events](/product/audience-data-and-segmentation/events/default-events) 

### Custom events
Unlike default events, which are universal across many apps and sectors, custom events are the events that you create specifically for your app. These events track specific actions unique to your needs, such as completing a workout or extending a subscription, and help you understand how users interact with your specific features. 

Custom Events require you to implement them on your side.


## Custom events implementation

### 1. Create events and set attributes 

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.

You can ask your marketing team to create events directly in the [Pushwoosh Control Panel](/product/audience-data-and-segmentation/events#1-create-events-in-pushwoosh-control-panel) or use the [createEvent](/developer/api-reference/events#createevent) API method. This involves specifying the event name and any associated data that you want to track.

### 2. Call /postEvent API

When an event you'd like to track occurs in your app, call the [`/postEvent`](/developer/api-reference/user-centric-api#postevent) API to send this event to Pushwoosh.

#### iOS

Call the [`postEvent`](/developer/api-reference/user-centric-api#postevent) to send an event to Pushwoosh:

<Tabs>
<TabItem label="Swift">
```swift
PWInAppManager.shared().postEvent("eventName", withAttributes: nil)
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
[[PushNotificationManager pushManager] postEvent:@“eventName” withAttributes:@{}];
```
</TabItem>
</Tabs>

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

<Tabs>
<TabItem label="Swift">
```swift
let attributes: [String : Any] = ["AttributedString" : "someString",
                                  "AttributeInt" : 42,
                                  "AttributeList" : [123, 456, "someString"],
                                  "AttributeBool" : true,
                                  "AttributeDate" : NSDate()]

PWInAppManager.shared().postEvent("eventName", withAttributes: attributes)
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
NSDictionary *attributes = @{ 
  @"AttributeString" : @"someString",
  @"AttributeInt" : @(42),
  @"AttributeList" : @[ @(123), @(456), @"someString" ],
  @"AttributeBool" : @YES,
  @"AttributeDate" : [NSDate date] 
};

[[PushNotificationManager pushManager] postEvent:@“eventName” withAttributes:attributes];
```
</TabItem>
</Tabs>

#### Android

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

Call the [`postEvent`](/developer/api-reference/user-centric-api#postevent) to send an event to Pushwoosh:

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

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

```java
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);
```

<Aside type="note">
You can also send events from [**In-App Javascript**](/developer/guides/messaging-channels/inapp-with-javascript/).
</Aside>