# Creating and Viewing a Counter Attribute

You can create a counter attribute to count or sum up values. This can be useful in situations such as:

* Counting Active User Sessions
* Article and Product/Page View Counts
* Monitor cart abandonment frequency
* Track LTV-related activities
* Track login-frequency for security/engagement
* Monitor support ticket submissions


Customer Journey Orchestration supports two types of counter attributes:

* **Sliding counter** : Get a count of events/actions. Create a sub-counter to retrieve counts within the counter duration for a smaller period of time. For example, create a sliding counter for a month with a sub-counter of a single week.


Other useful examples could include a variety across different applications:

* E-commerce
  * Product views in last 7 days (for recent interest scoring)
  * Purchases in last 30 days (for loyalty tier evaluation)
  * Cart additions in last hour (for immediate personalization)
* Subscription Businesses
  * Login frequency in last 14 days (for engagement health)
  * Feature usage in last 30 days (for upsell targeting)
  * Support tickets in last 90 days (for proactive outreach)
* Content/Media
  * Article reads in last 24 hours (for trending content)
  * Video completions in last week (for recommendation engine)
  * Search queries in last hour (for real-time suggestions)
* Marketing
  * Email clicks in last 7 days (for engagement scoring)
  * Campaign touchpoints in last 30 days (for frequency capping)
  * Website visits in last session (for exit-intent triggers)
* **Total counter** : Get a total count of a specific value on top of a historical base value. A Total counter combines a historical total (provided by Batch Backfill) with real-time events recorded after the last batch refresh — for example, tracking total lifetime purchases.


Other useful examples could include the following:

* Lifetime Value Tracking
  * Total purchases ever (for VIP customer identification)
  * Total dollars spent (for lifetime value segmentation)
  * Total loyalty points earned (for tier status)
* Engagement Milestones
  * Total logins since signup (for user maturity scoring)
  * Total articles read (for content engagement level)
  * Total features used (for product adoption depth)
* Achievement/Gamification
  * Total badges earned (for user profile display)
  * Total challenges completed (for achievement systems)
  * Total referrals made (for ambassador programs)
* Business Intelligence
  * Total support tickets ever (for customer health scoring)
  * Total downloads (for product popularity ranking)
  * Total sessions (for user stickiness analysis)
* Subscription Metrics
  * Total renewals (for churn prediction models)
  * Total upgrades (for customer growth tracking)
  * Total cancellations (for win-back campaigns)


If you want to use subdurations of time as a parameter as described in the examples above, it is recommended that you use the sliding Counter.

This topic includes:

* [Create a Counter Attribute](/products/customer-data-platform/real-time/creating-a-counter-attribute#create-a-counter-attribute)
* [View Counter Attributes](/products/customer-data-platform/real-time/creating-a-counter-attribute#view-counter-attributes)


## Prerequisites

To create a counter attribute, you must have *Full*[Data Workbench permissions](/products/control-panel/security/policies/policy-based-data-workbench-permissions) for all parent segments.

## Create a Counter Attribute

1. Open Treasure Console.
2. Navigate to the **Data Workbench > Parent Segments.**
3. Select a parent segment to which you want to add a counter attribute.
4. Select **Real-time Configuration**.
5. Select the **Attributes** tab, and then select **Add Attributes**.
6. Select **Counter**.


![](/assets/creating-counter-attributes-2024-07-11.64232de0ea0bcdaddf4ed5104c110f7718247732ba9687ff2cd9620b473f033e.cf3845cb.png)

1. Review the information in the following fields to complete the form, then select **Create**.


- **Name** (Required): Enter a name for your counter attribute.
- **System ID** (Required): Create a unique system ID for the attribute. A system ID is a string that starts with an alphabet or underscore (*) and is optionally followed by an alphanumeric and (*). No spaces or special characters are allowed. The system ID is case-sensitive. **Example** *systemID924*
- **Description**: Enter a description of your counter attribute.
- **Key event** (Required): Select a key event from the parent segment. Optionally, add filters to your key event. For more information, see [Configuring Event Definitions](/products/customer-data-platform/real-time/creating-a-real-time-configuration#configure-event-definitions).
- **Counter type** (Required): Select **Sliding** or **Total**. The criteria to complete these counter types are described in the following rows.


**Sliding counter settings**

- **Duration** (Required): Add the number of minutes, hours, or days for a timeline.
  * Select **+** **Add sub-duration**
    * **Name:** Create a name for the sub-duration attribute.
    * **System ID** : Create a system ID for this sub-duration attribute.
    * **Duration** : Add the number of minutes, hours, or days.
**Duration** All events within the duration period are stored in the attribute. For example, if the duration is one week, any events up to one week are saved in the attribute. As time progresses, any events exceeding the one-week period are removed.
**Sub-Duration**
  * A sub-duration must be specified for a sliding counter attribute to be accessed in a real-time journey and activation.
  * Extract the count for a smaller duration. Sub-durations cannot exceed the main counter's duration.
  * The maximum of sub-durations within a counter is 20.
- **Increment by**: Select one of the following:
  * **Value** : Keep the default increment value of 1 or change it to a different number to add to the counter settings.
  * **Value of event field** : Select the field to increment the counter, for example, amount.


**Total Counter Settings**

- **Duration**: Keep the default duration of one day or change it to a different number and time value.
- **Increment by**: Select one of the following:
  * **Value** : Keep the default increment value of one or change it to a different number to add to the counter settings.
  * **Value of event field** : Select the field to increment the counter, for example, amount.
- **Batch Backfill**: Configure the batch attribute that provides the historical base value for a Total counter. The batch value is **always** combined with real-time events occurring after the batch timestamp to produce the lifetime total — it is not a fallback used only when real-time data is absent.
Always configure Batch Backfill when using the Total counter type. Without it, the counter behaves as a sliding counter within a fixed window (max 60 days) instead of accumulating a true lifetime total.
Batch Backfill is not available for sliding counters.
  * **Batch attribute to backfill**: Select the batch attribute whose value serves as the historical base total.
  * **Batch attribute timestamp**: Select the field that stores the timestamp of the batch value, in Unix seconds format. Only events occurring **after** this timestamp are included in the real-time component of the total. The attribute with the most recent timestamp is used.


**Key Events with Null Element**

When using the Key Event Field Name, Null is treated the same as “False” when doing comparisons (for equals and not-equals).

For example:


```
> 1 == null
false
> 1 != null
true
> null != null
false
> null == null
true
```

## View Counter Attributes

After you have created one or more counter attributes, you can view them in the Data Workbench.

1. Open Treasure Console.
2. Navigate to the **Data Workbench** >**Parent Segments.**
3. Select a parent segment.
4. Select the ellipses in the row where the counter attribute is listed.


![](/assets/creating-a-counter-attribute-2024-07-30.93e78768acd524f3e435c78fbb37d6e46c41b126b0183d480a9a27cf04e8bc64.cf3845cb.png)

1. Select **View Details**.


Note: Upon expiry, events within a counter are evicted when they exceed the counter's duration. The counter attribute itself is not deleted.

See also [Real-time Attribute FAQs](/products/customer-data-platform/real-time/real-time-attribute-faqs).