# Collect reader data

Pushwoosh needs to know who your readers are and what they read, watch, or listen to. The User ID tells Pushwoosh who the reader is, events record the actions, and tags keep the current state of each reader, such as the topics they follow.

<Aside type="tip" title="Let AI Assistant create the events and tags">
[AI Assistant](/product/pushwoosh-ai/ai-assistant/) can create the events and tags from this page in your application. Send it the link to the page and ask it to make the tags User-specific. It creates them right away. When it is done, check the result in the Control Panel.
</Aside>

## Identify readers by User ID

<Aside type="caution" icon="setting" title="Developer assistance needed">
Setting the User ID is a change in your app's code. Share [Collecting User IDs](/developer/first-steps/collecting-user-ids/#setuserid-sdk-method) with your developers.
</Aside>

Pushwoosh links all of a reader's devices to one User ID, so your segments and journeys treat one person as one reader.

By default, Pushwoosh uses each device's hardware ID (HWID) as its User ID. A reader who reads on a phone and watches on a tablet then counts as two readers, and an episode started on the phone can't be matched with the same episode finished on the tablet.

To avoid this for readers who log in, set your own account ID as their User ID:

1. Choose the ID to use. Take the account ID that your service already assigns to each registered reader or subscriber.
2. Ask your developers to call `setUserId` with this ID when the reader logs in or signs up.
3. Check the result. Log in to the app on a test device, then open **Audience** → **User explorer**, search by **User Id**, and enter the account ID. The reader's profile opens.

Many readers of a news app never log in. They keep the HWID as their User ID, which Pushwoosh sets for them, and they still get pushes, enter journeys, and appear in segments on that device. What they read on another device counts for another reader.

To learn more about how User IDs relate to devices, see [Users and User IDs](/product/pushwoosh-knowledge-hub/users-userids/).

## Set up the events

Events are how Pushwoosh learns what a reader does. Create them first, because [segments](/tutorials/industry-playbooks/media-and-streaming/build-the-segments/) group readers by the events they triggered, and [journeys](/tutorials/industry-playbooks/media-and-streaming/build-the-journeys/) start when an event happens.

Plan both the events and their attributes before you build anything. [Recommended events for media](/product/audience-data-and-segmentation/events/recommended-events-for-media/) lists ready-made events with attributes, and [Custom events](/product/audience-data-and-segmentation/events/custom-events/) explains how to define your own.

There are two kinds of events:

* [Default events](#default-events): device registration and app open. The SDK sends them, and you do not create them in the Control Panel.
* [Custom events](#custom-events): content read, topic followed, episode started, paywall viewed, and others. Your developers [send them from the app](#send-the-events-from-the-app), and Pushwoosh creates each one the first time it arrives. To choose the attribute types yourself, create the event in the Control Panel first. See [Custom events](/product/audience-data-and-segmentation/events/custom-events/) and [Events created automatically](/product/audience-data-and-segmentation/events/#events-created-automatically).

### Default events

The SDK sends these events for you. You need them to find readers who stopped opening the app before your custom events have enough history.

* [`PW_DeviceRegistered`](/product/audience-data-and-segmentation/events/default-events/#pw_deviceregistered): a device received its first [push token](/product/pushwoosh-knowledge-hub/device-identifiers/#push-token), the address Pushwoosh uses to send a push to that device.
* [`PW_ApplicationOpen`](/product/audience-data-and-segmentation/events/default-events/#pw_applicationopen): a reader opened the app.

`PW_DeviceRegistered` fires when the app requests the token, not at install:

* The SDK requests the token only when the app calls `registerForPushNotifications`. On iOS, this call also shows the permission prompt, and the token arrives whatever the reader answers.
* If the app asks for permission later than the first launch, the event fires at that moment.
* To catch new readers who create an account, use the `Signed up` custom event instead. See [Choose the events to track](#choose-the-events-to-track).

An event appears in **Audience** → **Events** after the SDK sends it for the first time. For details on these and other default events, see [Default events](/product/audience-data-and-segmentation/events/default-events/).

### Custom events

Custom events record what happens in your app, such as reading an article or starting an episode. You choose which ones the app needs, your developers send them, and you check that they arrive.

#### Choose the events to track

Choose the events your app needs and the attributes each one carries. The tables list examples: use them as they are, rename them, or add your own. A news app needs the reading events, a streaming app the episode events. Track only the events that the journeys you launch need.

##### Events for the minimum setup

This event is enough to launch the [minimum setup](/tutorials/industry-playbooks/media-and-streaming/#minimum-setup-to-start-messaging-readers).

| Event | When it fires | Key attributes | What it drives |
| --- | --- | --- | --- |
| [Content read](/product/audience-data-and-segmentation/events/recommended-events-for-media/#content-read) | Reader opens an article, a video, or a podcast episode | `article_id` (string), `category` (string) | Active readers and At-risk readers segments, conversion goal of Win-back for inactive readers |

##### Events for other journeys

You can add these events together with the first one or later, when you build the journeys that use them. If readers subscribe through the App Store or Google Play, Pushwoosh records the store events for you. See [Track subscriptions from the stores](#track-subscriptions-from-the-stores).

| Event | When it fires | Key attributes | What it drives |
| --- | --- | --- | --- |
| [Content preferences](/product/audience-data-and-segmentation/events/recommended-events-for-media/#content-preferences) | Reader follows a topic, a show, or an author | `topic` (string) | Conversion goal of Welcome and topic choice, push permission flow |
| Signed up | Reader creates an account | `signup_source` (string) | Welcome and topic choice journey |
| Episode started | Reader starts an episode of a series or a podcast | `series_id` (string), `series_name` (string), `episode_id` (string) | Continue watching journey |
| Episode completed | Reader finishes the episode | `series_id` (string), `episode_id` (string) | Continue watching journey |
| Paywall viewed | Reader opens content that needs a subscription and sees the paywall | `article_id` (string) | Paywall hitters segment, Paywall follow-up journey |
| Subscription started | Reader buys a subscription on your website or in your own billing | `plan` (string), `__amount` (decimal (price)), `__currency` (string) | Conversion goal of Paywall follow-up, revenue |
| [Subscription canceled](/product/audience-data-and-segmentation/events/recommended-events-for-subscription-management/#subscription-canceled) | Reader cancels a subscription bought on your website or in your own billing | `plan` (string) | Cancelled subscription journey for website subscribers |

<Aside type="caution" title="Attribute types are set by the first value">
Pushwoosh sets the type of an attribute from its first value, and the type does not change later. If the first `__amount` arrives as a whole number, such as `10`, the attribute becomes Integer, and later amounts lose their decimals.

To choose the types yourself, create the event and its attributes in the Control Panel before the app sends it:

* **decimal (price):** amounts that can have a fraction, such as a price.
* **string:** text, such as an ID.

For all attribute types, see [Custom events](/product/audience-data-and-segmentation/events/custom-events/).
</Aside>

<span id="send-the-events-from-the-app" />

#### Send the events from the app and your server

<Aside type="caution" icon="setting" title="Developer assistance needed">
Sending events is a change in your app's code. Share [Events for developers](/developer/guides/audience-and-segmentation/events/) and the [media event examples](/developer/guides/audience-and-segmentation/events/custom-events-examples#media) with your developers. They send each event with `postEvent` at the moment the action happens.
</Aside>

Agree with your developers which events the app sends and which attributes each one carries. The names of the events and attributes must match exactly.

The app sends each event with `postEvent`. Your server sends `Subscription started`, because the app does not know about a subscription bought on your website. It uses the same `postEvent` method of the [API](/developer/api-reference/user-centric-api/#postevent).

To check that an event arrived, open **Audience** → **User explorer**, find a test reader, and open the **Events history** tab.

##### Code examples for your developers

These examples show what your developers send for the events above.

The app sends `Episode started` with its attributes like this:

<Tabs>
<TabItem label="Android">
```java
TagsBundle attributes = new TagsBundle.Builder()
    .putString("series_id", "S-204")
    .putString("series_name", "The Long Road")
    .putString("episode_id", "S-204-E03")
    .build();

InAppManager.getInstance().postEvent("Episode started", attributes);
```
</TabItem>
<TabItem label="iOS">
```swift
PWInAppManager.shared().postEvent("Episode started", withAttributes: [
    "series_id": "S-204",
    "series_name": "The Long Road",
    "episode_id": "S-204-E03"
])
```
</TabItem>
</Tabs>

The server sends `Subscription started` with the reader's `userId` instead of a device, and a [Device API token](/developer/api-reference/api-access-token/#device-api-token) in the `Authorization: Token <token>` header:

```json
POST https://api.pushwoosh.com/json/1.3/postEvent

{
  "request": {
    "application": "XXXXX-XXXXX",
    "userId": "reader-20931",
    "event": "Subscription started",
    "attributes": {
      "plan": "monthly",
      "__amount": 9.99,
      "__currency": "EUR"
    }
  }
}
```

### Track revenue from subscriptions

Pushwoosh counts revenue from `PW_Conversion`, which records the amount and currency of every purchase in one format. You need it to compare revenue in [Conversion events](/product/audience-data-and-segmentation/events/conversion-events/).

You do not need a separate call. Send `Subscription started` with these attributes:

* `__amount`: the price of the subscription, as a number.
* `__currency`: the currency, as an ISO 4217 code, such as `EUR`. Pushwoosh drops a currency that is not a valid code.

The first time the event arrives with both attributes, Pushwoosh turns on revenue tracking for it, unless you already set up revenue for this event in [Conversion events](/product/audience-data-and-segmentation/events/conversion-events/). From then on, each `Subscription started` with these attributes also records a `PW_Conversion` event with the same amount and currency. See [Automatic revenue mapping](/developer/api-reference/user-centric-api/#automatic-revenue-mapping).

<Aside type="caution">
Use only one path per subscription. If your code also sends `PW_Conversion` for the same purchase, Pushwoosh records two separate conversion events.
</Aside>

### Track subscriptions from the stores

If readers subscribe in the app through the App Store or Google Play, Pushwoosh receives the status changes of their subscriptions from the stores. Each change arrives as a `PW_Subscription*` event with the `productID` and `expiresAt` attributes, for example:

* `PW_SubscriptionStart`: a reader subscribes.
* `PW_SubscriptionCancel`: a reader turns off auto-renewal. The subscription stays active until the paid period ends.
* `PW_SubscriptionResume`: a reader turns auto-renewal back on, or subscribes again in the App Store. A new purchase in Google Play arrives as `PW_SubscriptionStart`.
* `PW_SubscriptionExpired`: the subscription has ended.

The store events don't show a free trial: a trial that starts arrives as an ordinary `PW_SubscriptionStart`, and nothing marks its end or conversion. To remind readers before a trial ends, send your own event from your server, for example [`Free trial started`](/product/audience-data-and-segmentation/events/recommended-events-for-subscription-management/#free-trial-started) with the trial end date in `expiry_date`. For more subscription events, such as renewals, see [Recommended events for subscription management](/product/audience-data-and-segmentation/events/recommended-events-for-subscription-management/).

Use these events to start journeys, for example an offer to a reader who turned off auto-renewal. See [Cancelled subscription](/tutorials/industry-playbooks/media-and-streaming/build-the-journeys/subscriptions-and-win-back/#cancelled-subscription).

<Aside type="caution" icon="setting" title="Developer assistance needed">
The app must pass the reader's Pushwoosh HWID with each purchase:

* On iOS, as `appAccountToken`.
* On Android, as `obfuscatedAccountId`. The app passes the value of the SDK's `getSubscriptionAccountId()`, which is the Application Code and the HWID together, not the HWID alone.

Without it, Pushwoosh receives the notification but records no event. Share [App Store subscription tracking](/product/integrations/app-store-subscription-tracking/) and [Google Play subscription tracking](/product/integrations/google-play-subscription-tracking/) with your developers.
</Aside>

The store events carry no amount, so they do not record revenue. Subscriptions bought on your website don't reach the stores, so send them as `Subscription started` from your server, and their cancellations as `Subscription canceled`.

## Store reader data in tags

A [tag](/product/audience-data-and-segmentation/user-data-tags/) is a value that Pushwoosh stores on a reader's profile, such as the topics the reader follows or whether the reader is a subscriber. An event records what happened, and a tag keeps the current state. Tags help you to:

* Send a message only to readers with a certain value, for example a news alert only to readers who follow politics.
* Leave readers out of a message, for example subscribers out of a subscription offer.

Tags are optional. The journeys in this playbook run on events and on default tags that Pushwoosh sets itself, so you can start without your own tags. Add them to send news alerts by topic or to tell subscribers apart. See [Segments by tags](/tutorials/industry-playbooks/media-and-streaming/build-the-segments/#segments-by-tags).

### Your own tags

Your developers send tag values from the app or your server, or you can [import them from a CSV file](/product/audience-data-and-segmentation/user-data-tags/update-tags-via-csv/). Pushwoosh handles a new tag like this:

* On most accounts, Pushwoosh creates the tag the first time your developers send it, as a User-specific tag.
* If a tag doesn't appear in the Control Panel after the app sends it, create it there.
* To choose the type of a tag yourself, create the tag in the Control Panel first. See [Tags](/product/audience-data-and-segmentation/user-data-tags/tags/).

These tags are examples. Rename them to match your service, and add your own:

| Tag | Type | Example | What it drives |
| --- | --- | --- | --- |
| `followed_topics` | List | `politics`, `football` | News alerts to the readers who follow a topic |
| `is_subscriber` | Boolean | `true` | Leave subscribers out of subscription offers, or send them their own content |

A List tag keeps several values for one reader: a reader who follows two topics is in the segment of each topic.

Ask your developers to:

* Update `followed_topics` every time the reader follows or unfollows a topic.
* Set `is_subscriber` when a subscription starts or ends.

When you create a tag in the Control Panel, keep [**User-specific**](/product/audience-data-and-segmentation/user-data-tags/tags/#tag-scope-general-vs-user-specific) turned on, as it is by default. Pushwoosh then keeps one value per User ID, so the value belongs to the reader and not to one of their devices. See [Identify readers by User ID](#identify-readers-by-user-id).

When a reader logs in, the events and User-specific tags that the device recorded before stay with the HWID. Device-specific tags, which have **User-specific** turned off, move with the device to the new User ID.

### Default tags

Pushwoosh stores these [default tags](/product/audience-data-and-segmentation/user-data-tags/tags/#default-tags) for every device, so you do not create them:

* **Language:** the language of the device. Pushwoosh uses it to send each reader the message in their own language.
* **Last Application Open:** when the app was last opened on the device. Use it to find readers who stopped opening the app.
* **Push Alerts Enabled:** whether notifications are allowed in the device settings. Use it to show an in-app message only to readers who have not allowed them yet.
* **Country:** the country of the device. Use it to send a local news alert only to readers in one region.