# Accoil Analytics Cloud Mode Integration

After you have successfully instrumented Accoil Analytics as a destination in RudderStack, follow this guide to correctly send your events to Accoil Analytics in [cloud mode]({{< ref "/destinations/rudderstack-connection-modes.md#cloud-mode" >}}).

Find the open source transformer code for this destination in the [GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/cdk/v2/destinations/accoil_analytics).

{{< info >}}
Accoil simplifies event tracking by aggregating daily event counts.
{{< /info >}}

## Identify

You can use the [`identify`]({{< ref "event-spec/standard-events/identify.md" >}}) call to identify a user and their associated attributes.

A sample `identify` call is shown below:

```javascript
rudderanalytics.identify("1hKOmRA4GRlm", {
  email: "alex@example.com",
  name: "Alex Keener",
  createdAt: '2023-05-12T08:00:00Z' // ISO 8601 or Unix timestamp format
});
```

#### Supported mappings

| RudderStack property | Accoil property | Notes |
| :----------------------- | :------------------ | :------- |
| `userId` <br/> `traits.userId` <br/> `traits.id` <br/> `context.traits.userId` <br/> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `userId` | - |
| `traits` <br/> `context.traits` | Sent as is to Accoil | See [Supported traits](#supported-traits) for details. |
| `timestamp` <br/> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | ISO 8601 format datetime or UNIX timestamp. This field is automatically added by RudderStack while sending the final event payload to Accoil. |

#### Supported traits

| RudderStack trait | Notes |
| :-------------------- | :------- |
| `email` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | Used to identify users across multiple platforms. |
| `name` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | Displays the user's name in Accoil. If no name is provided, the email address is displayed instead. |
| `createdAt` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | Signifies when was the user created. Make sure to send this field in the ISO 8601 or UNIX timestamp format for accurate tenure tracking. |
| `role` <br/> <span style="color: #4D4DFF;font-size:12px;">Suggested</span> | Describes the user’s role in your product, for example, Admin, Owner, Team Member, etc. |
| `accountStatus` <br/> <span style="color: #4D4DFF;font-size:12px;">Suggested</span> | Captures the account status of the user - it can be helpful in segmenting users. Possible options include: `Free`, `Trial`, `Paid`, and `Cancelled`. |

## Track

The [`track`]({{< ref "event-spec/standard-events/track.md" >}}) call lets you record the user events along with their associated properties.

A sample `track` call is shown below:

```javascript
rudderanalytics.track("Product Added", {
  item: "Book",
  name: "Archies",
  price: 25.00
});
```
{{< warning >}}
Accoil only stores traits sent with `identify` and `group` events - properties passed within the `track` events are not stored. Accoil records only the event names and counts.
{{< /warning >}}

#### Supported mappings

| RudderStack property | Accoil property | Note |
| :----------------------- | :------------------ | :------- |
| `userId` <br/> `traits.userId` <br/> `traits.id` <br/> `context.traits.userId` <br/> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `userId` | Persisted from the previously made `identify` call. |
| `event` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Event name | - |
| `timestamp` <br/> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | ISO 8601 format datetime or UNIX timestamp. This field is automatically added by RudderStack while sending the final event payload to Accoil. |

## Group

You can use the [`group`]({{< ref "event-spec/standard-events/group.md" >}}) event to link identified users to accounts and records account-level attributes.

A sample `group` call is as shown below:

```javascript
rudderanalytics.group("group123", {
  name: "MyGroup",
  industry: "IT",
  employees: 450,
  plan: "basic",
  createdAt: '2021-03-15T09:00:00Z',  // ISO 8601 or UNIX timestamp format
  mrr: 3000,
  status: 'active'
});
```

#### Supported mappings

| RudderStack property | Accoil property | Note |
| :----------------------- | :------------------ | :------- |
| `userId` <br/> `traits.userId` <br/> `traits.id` <br/> `context.traits.userId` <br/> `context.traits.id` <br /><span style="color: #4D4DFF;font-size:12px;">Required</span> | `userId` | - |
| `groupId` <br /><span style="color: #4D4DFF;font-size:12px;">Required</span> | `groupId` | - |
| `traits` | Sent as is to Accoil | See [Supported group traits](#supported-group-traits) for details. |
| `timestamp` <br/> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | ISO 8601 format datetime or UNIX timestamp. This field is automatically added by RudderStack while sending the final event payload to Accoil. |

#### Supported group traits

| RudderStack trait | Note |
| :-------------------- | :------- |
| `name` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | The account name. Without a name, accounts are displayed using a numeric ID, making them harder to identify.  |
| `createdAt` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | Helps calculate the account's tenure. If no `createdAt` is provided, the earliest `createdAt` from the associated users is used. <br /><br />**Note**: Make sure to send this field in the ISO 8601 or UNIX timestamp format for accurate tenure tracking. |
| `status` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | The status of the account subscription. Possible options include: `Free`, `Trial`, `Paid`, `Cancelled` |
| `plan` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | The plan type helps in segmenting accounts by their subscription tier (for example, starter, pro, enterprise). |
| `mrr` <br/> <span style="color: #4D4DFF;font-size:12px;">Recommended</span> | Monthly recurring revenue (MRR) used for segmenting accounts by value. It also allows Accoil to show the dollar value of different segments. Ideally this is passed in cents, for example, `$99` becomes `9900`.  |

## Page

The [`page`]({{< ref "event-spec/standard-events/page.md" >}}) call allows you to record your website's page views, with the additional relevant information about the viewed page.

{{< info >}}
RudderStack sends the `page` events as `track` events to Accoil for easier monitoring of user navigation.
{{< /info >}}

A sample `page` call is as shown below:

```javascript
rudderanalytics.page("Cart", "Cart Viewed");
```

#### Supported mappings

| RudderStack property | Accoil property | Note |
| :----------------------- | :------------------ | :------- |
| `userId` <br/> `traits.userId` <br/> `traits.id` <br/> `context.traits.userId` <br/> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `userId` | Persisted from the previously made `identify` call. |
| `name` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Name of the viewed page. | - |
| `timestamp` <br/> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | ISO 8601 format datetime or UNIX timestamp. This field is automatically added by RudderStack while sending the final event payload to Accoil. |

## Screen

The [`screen`]({{< ref "event-spec/standard-events/screen.md" >}}) call lets you record your users' mobile screen views with any additional information about the viewed screen.

{{< info >}}
RudderStack sends the `screen` events as `track` events to Accoil for easier monitoring of user navigation.
{{< /info >}}

A sample `screen` call is shown below:

```objectivec
[[RSClient sharedInstance] screen:@"Main"
                properties:@{@"category" : @"Home"}];
```

#### Supported mappings

| RudderStack property | Accoil property | Note |
| :----------------------- | :------------------ | :------- |
| `userId` <br/> `traits.userId` <br/> `traits.id` <br/> `context.traits.userId` <br/> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `userId` | Persisted from the previously made `identify` call. |
| `name` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Name of the viewed screen. | - |
| `timestamp` <br/> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | ISO 8601 format datetime or UNIX timestamp. This field is automatically added by RudderStack while sending the final event payload to Accoil. |
