Personalization with StorifyMe
In case you want your stories to be dynamic and to show different content to different users you would can do that in a few simple steps.
Just map your dynamic personal data in StorifyMe Admin app, and after you provide it with the SDK, the stories would automatically change and adapt to the user that is consuming content making them feel VIP with stories built just for them.
You need to have the working StorifyMe setup as described in Initial SDK Setup
Set personal and dynamic data
Enable dynamic personalization of elements using StorifyMe's Dynamic data feature in the app. Then, map the personal fields with the elements.
From the SDK, easily pass personalized data through to dynamically modify and adapt text, images, videos and other elements and provide a tailored user experience within your application for your user.
The personal or dynamic data can be set with setDynamicData(dynamicIntegrationId:, data:) multiple times for different dynamicIntegrationId.
storifyMeWidget.setDynamicData(
dynamicIntegrationId: "example-dynamic-integration-id",
data: ["first-example-key": "first-example-value",
"second-example-key": "second-example-value"])
Set customerId for User Actions Tracking
To track user actions within the StorifyMe Widget, such as when a user clicks on a poll or performs any other action, you can set the customerId using the following steps:
var conf = StorifyMeWidgetConfig()
conf.setCustomerId(customerId: "customer-id-example")
let storifyMeWidget = StorifyMeWidget()
storifyMeWidget.setWidgetConfig(config: widgetConf)
storifyMeWidget.setWidgetId(widgetId: WIDGET_ID)
storifyMeWidget.load()
By setting the customerId for user actions tracking, you enable the StorifyMe SDK to capture and provide information about the specific user actions performed within the widget. The customerId can be used to identify the user or correlate their actions with specific events or data in your system.
Set Content Type for Widget
You can now specify the type of content to be displayed within the StorifyMe widget using the setContentType method. This feature allows you to filter and display stories or reels based on their status, such as liked, bookmarked, or all.
Enum: StorifyMeWidgetContentType
The StorifyMeWidgetContentType enum represents the content type to be displayed within a StorifyMe widget.
liked: Display only liked stories or reels within the widget.bookmarked: Display only bookmarked stories or reels within the widget.all(Default): Display all stories or reels within the widget.
Method: setContentType
This method sets the content type for the StorifyMe widget.
var conf = StorifyMeWidgetConfig()
conf.setContentType(contentType: .liked)
storifyMeWidget.setWidgetConfig(config: conf)
Audience Segmentation (CDP Integration)
StorifyMe integrates with Customer Data Platforms (CDPs) like Braze to show personalized stories based on user segments. This allows you to display different stories to different audience groups automatically.
How It Works
- Configure your CDP integration in the StorifyMe dashboard
- Sync audience segments from your CDP (e.g., "Premium Users", "Active Shoppers")
- Tag stories with audience segments in StorifyMe
- Use
setSegmentUserId()in your app to resolve user segments - Stories automatically filter based on the user's segments
Method: setSegmentUserId
This method resolves audience segments for a user from your connected CDP and merges them with any existing segments configured in the widget.
Task {
// Resolve user segments before loading widget
await storifyMeWidget.setSegmentUserId("user@example.com")
// Load widget - will show personalized stories
storifyMeWidget.load()
}
Important Notes:
- Must be called before
load()to apply personalization - Use the same user identifier configured in your CDP (email, external_id, etc.)
- Segments are cached based on the
cacheUntiltimestamp from the server (typically 30 minutes) - If resolution fails, widget loads normally with default segments (graceful degradation)
- Audience tags are merged with any segments set via
setSegments()- duplicates are removed - Multiple calls with the same userId won't trigger duplicate API requests (protected by actor)
Method: getSegments
Retrieve the current segments (tags) configured for the widget, including both manually set segments and audience segments.
var config = StorifyMeWidgetConfig()
config.setSegments(tags: ["tag1", "tag2"])
// After resolving audience
Task {
await storifyMeWidget.setSegmentUserId("user@example.com")
// Get all segments (manual + audience)
let allSegments = config.getSegments()
print("Active segments: \(allSegments)")
}
Complete Example
import UIKit
import StorifyMe
class ViewController: UIViewController {
private let storifyMeWidget = StorifyMeWidget()
override func viewDidLoad() {
super.viewDidLoad()
// Configure widget with base segments
var config = StorifyMeWidgetConfig()
config.setSegments(tags: ["mobile_app_users"])
config.setCustomerId(customerId: "customer-123")
storifyMeWidget.setWidgetConfig(config: config)
storifyMeWidget.setWidgetId(widgetId: YOUR_WIDGET_ID)
// Add to view
view.addSubview(storifyMeWidget)
// Setup constraints...
// Resolve CDP audience segments and load
Task {
// Resolve audience segments for this user
await storifyMeWidget.setSegmentUserId("user@example.com")
// Load widget with personalized content
storifyMeWidget.load()
}
}
}
Testing Your Integration
- Open the StorifyMe dashboard and navigate to your CDP integration
- Verify your user exists in synced segments
- Tag some stories with audience segments (format:
seg_segment_name) - Run your app with
setSegmentUserId()and verify:- Network request to
/widgets/{accountId}/audience/{userId}/resolve - Response contains expected segment tags
- Only stories tagged with matching segments are displayed
- Network request to
Audience segments are cached based on the server's cacheUntil timestamp (typically 30 minutes). Subsequent calls with the same userId return instantly from cache until expiration, reducing API calls and improving performance.
If audience resolution fails (network error, user not found, etc.), the widget will still load successfully with any manually configured segments. Check console logs for warning messages if personalization isn't working as expected.