// Read the personalized feed for a given user
const params = { user_id: '123', feed_slug: 'timeline' };
client.personalization.get('personalized_feed', params).then(
(resolution) => console.log(resolution["response"]["data"]),
(rejection) => console.log(rejection)
);
// Our data science team will typically tell you which endpoint to use
const params = { user_id: '123', source_feed_slug: 'timeline', target_feed_slug: 'user' };
client.personalization.get('discovery_feed', params).then(
(resolution) => console.log(resolution["response"]["data"]),
(rejection) => console.log(rejection)
);
Personalization Introduction
Introduction to Personalization and Analytics
Personalization is a powerful feature. It enables you to leverage machine learning to optimize what’s shown in the feed. The 5 most common use cases are:
Famous examples of discovery feeds are: Instagram’s explore section, and Pinterest’s main feed. Edge rank is used by Facebook and LinkedIn. Stream uses 3 data sources for personalization:
1. Feeds & Follows
The best way to understand how feeds and follows work is to try our 5-minute interactive tutorial.
2. Analytics
The purpose of analytics is to track which activities a user is looking at and what they are engaging with. Basically, you want to track everything that indicates a user’s interest in something. Common examples include:
Clicking on a link
Likes or comments
Sharing an activity
Viewing another user’s profile page
Search terms
The events and data you want to track are often different than what you traditionally track in Google Analytics or Mixpanel. Stream’s analytics is designed to run alongside your existing analytics solution.
3. Collections
Collections enable you to sync information to Stream that’s not captured by analytics or feeds. Common examples include user profiles and product information.
Personalized Feed
Personalization is custom for every enterprise customer of Stream. The SDK exposes a flexible GET method to enable you to make authenticated get requests to personalization easily:
# Read the personalized feed for a given user
client.personalization.get('personalized_feed', user_id=123, feed_slug='timeline')
# Our data science team will typically tell you which endpoint to use
client.personalization.get('discovery_feed', user_id=123, source_feed_slug='timeline', target_feed_slug='user')
# Read the personalization feed for a given user
client.personalization.get('personalized_feed', user_id: 123, feed_slug: 'timeline')
# Our data science team will typically tell you which endpoint to use
client.personalization.get('discovery_feed', user_id: 123, source_feed_slug: 'timeline', target_feed_slug: 'user')
// Read the personalized feed for a given user
$client->personalization()->get('personalized_feed', [
'user_id' => 123,
'feed_slug' => 'timeline',
]);
// Our data science team will typically tell you which endpoint to use
$client->personalization->get('discovery_feed', [
'user_id' => 123,
'source_feed_slug' => 'timeline',
'target_feed_slug' => 'user',
]);
// Read the personalization feed for a given user
client.personalization().get("personalized_feed", new ImmutableMap.Builder<string, object>()
.put("user_id", 123)
.put("feed_slug", "timeline")
.build());
// Our data science team will typically tell you which endpoint to use
client.personalization().get("discovery_feed", new ImmutableMap.Builder<string, object>()
.put("user_id", 123)
.put("source_feed_slug", "timeline")
.put("target_feed_slug", "user")
.build());
// Read the personalization feed for a given user
resp, err := client.Personalization().Get(context.TODO(), "personalized_feed", map[string]any{
"user_id": 123,
"feed_slug": "timeline",
})
if err != nil {
panic(err)
}
// Our data science team will typically tell you which endpoint to use
resp, err := client.Personalization().Get(context.TODO(), "discovery_feed", map[string]any{
"user_id": 123,
"source_feed_slug": "timeline",
"target_feed_slug": "user",
})
if err != nil {
panic(err)
}
// Read the personalized feed for a given user
var params = {'user_id': 'john-doe', 'feed_slug': 'timeline'};
client.personalization.get('personalized_feed', params: params);
//Our data science team will typically tell you which endpoint to use
params = {
'user_id': 'john-doe',
'source_feed_slug': 'timeline',
'target_feed_slug': 'user'
};
await client.personalization.get('discovery_feed', params: params);
Follow Suggestions
Stream makes it easy to add follow-suggestions to your app. Simply make the API call shown below to retrieve a list of follow suggestions.
suggestions = client.personalization.get('follow_recommendations', target_feed_slug='user', user_id='123', source_feed_slug='timeline')
print(suggestions)
Follow suggestions are disabled by default. Contact support so we can enable it for your organization.
By default the follow-suggestions are based on a standardized graph analysis algorithm. Our data science team can work with you to create a customized algorithm for your app.
Contact sales@getstream.io to learn more.