Other/REST
Impressions Confused about "Impressions"?
Let us know how we can improve our documentation:
Confused about "Impressions"?
Let us know how we can improve our documentation:
LAST EDIT Jan 26 2021
Tracking impressions allows you to learn what specific users are not interested in. If the app often shows posts about football, and the user never engages with those posts, we can conclude that we're displaying the wrong content. The code below shows how to track that a user viewed 3 specific activities:
1
2
3
4
5
6
7
8
9
10
11
12
13
const impression = {
'content_list': [
{
'foreign_id': 'post:42',
'actor': {'id': 'user:2353540'},
'verb': 'share',
'object': {'id': 'song:34349698'},
}
],
'feed_id': 'timeline:tom'
};
client.trackImpression(impression);
1
2
3
4
5
6
7
8
9
10
// track an impression
StreamImpression *event = [StreamImpression createImpressionEventWithContentList:@[@"song:34349698", @"song:34349699", @"song:34349697"]];
// (optional) the feed where this content is coming from
event.feedId = @"flat:tommaso";
// (optional) the location in your app. ie email, profile page etc
event.location = @"ios-app";
// send the impression events
[[StreamAnalytics sharedInstance] send:event];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
client.send(new Impression.EventBuilder()
.withContentList(
new Content.ContentBuilder()
.withForeignId("tweet:34349698")
.withAttribute("verb", "share")
.withAttribute("actor", new ContentAttribute("1", "user1"))
.build(),
new Content.ContentBuilder()
.withForeignId("tweet:34349699")
.build(),
new Content.ContentBuilder()
.withForeignId("tweet:34349610")
.build()
)
.withFeedId("flat:tommaso")
.withLocation("android-app")
.build()
);
Be sure to use the same Foreign Ids as used in your feeds. This allows Stream to understand the content of the activities.
ParametersCopied!Confused about "Parameters"?
Let us know how we can improve our documentation:
Confused about "Parameters"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
content_list | list of strings or objects | The list of content the user is looking at. Either a list of IDs or objects. | - | |
feed_id | string | The feed the user is looking at. | - | ✓ |
location | string | The location in your app (i.e. email, homepage, profile page, etc.) | - | ✓ |