TagsBundle
Immutable, thread-safe collection of tags for user segmentation and personalization.
TagsBundle stores key-value pairs that represent user attributes, preferences, and behaviors. Tags enable targeted push notifications, audience segmentation, and personalized content delivery through the Pushwoosh platform. Once built, a TagsBundle instance is immutable and can be safely shared across threads.
Building vs Reading Tags:
- Use Builder when you need to create a custom tag collection for multiple operations
- Use Tags utility methods for simple, one-off tag operations
- Use sendTags to sync tags with Pushwoosh servers
Supported Tag Types:
- Integer - for demographics, counters, scores (age, level, points)
- Long - for timestamps, large IDs (registration_timestamp, user_id)
- Boolean - for flags, subscriptions (email_subscribed, premium_user)
- String - for profile data, categories (name, gender, favorite_category)
- List - for multi-value attributes (interests, purchased_products)
- Date - for milestones, events (last_purchase, subscription_end)
Thread Safety: TagsBundle is immutable after creation. The Builder uses ConcurrentHashMap to allow safe concurrent tag additions during construction.
Usage Example (E-commerce App):
// Building tags for a premium customer
TagsBundle tags = new TagsBundle.Builder()
.putString("customer_tier", "premium")
.putInt("lifetime_orders", 15)
.putLong("customer_since", System.currentTimeMillis())
.putBoolean("newsletter_subscribed", true)
.putList("favorite_categories", Arrays.asList("electronics", "books"))
.putDate("last_purchase", new Date())
.build();
// Sending tags to Pushwoosh
Pushwoosh.getInstance().sendTags(tags);
// Reading tags from bundle
String tier = tags.getString("customer_tier"); // "premium"
int orders = tags.getInt("lifetime_orders", 0); // 15
List<String> categories = tags.getList("favorite_categories"); // ["electronics", "books"]
// Converting to JSON for API calls
JSONObject json = tags.toJson();
Content copied to clipboard
See also
Types
Link copied to clipboard
Builder for constructing TagsBundle instances using the Builder pattern.