.Net / C#

Engagements

LAST EDIT Jan 26 2021

Tracking Engagements

Copied!

The snippet below shows an example of how to track engagements. Engagement examples include likes, comments, profile views and link clicks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const engagement = { 
  // the label for the engagement, ie click, retweet etc. 
  'label': 'click', 
  // the ID of the content that the user clicked 
  'content': { 
    'foreign_id': 'tweet:34349698' 
  }, 
  // score between 0 and 100 indicating the importance of this event  
  // IE. a like is typically a more significant indicator than a click 
  'score': 2, 
  // (optional) the position in a list of activities 
  'position': 3, 
  // (optional) the feed the user is looking at 
  'feed_id': 'user:thierry', 
  // (optional) the location in your app. ie email, profile page etc 
  'location': 'profile_page' 
}; 
 
client.trackEngagement(engagement); 
client.trackEngagements([engagement1, engagement2])
1
2
3
4
5
6
7
8
StreamEngagement *event = [StreamEngagement createEngagementEvent:@"click" withContent: @{@"foreign_id":@"message:34349698"}.mutableCopy]]; 
 
event.position = @"3"; 
event.boost = @2; 
event.feedId = @"user:thierry"; 
event.location = @"profile_page"; 
 
[[StreamAnalytics sharedInstance] send:event];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
client.send(new Engagement.EventBuilder() 
    .withFeedId("user:thierry") 
    .withContent( 
        new Content.ContentBuilder() 
            .withForeignId("message:34349698") 
            .withAttribute("verb", "share") 
            .withAttribute("actor", new ContentAttribute("1", "user1")) 
            .build() 
        ) 
    .withBoost(2) 
    .withLocation("profile_page") 
    .withPosition("3")                 
    .build() 
);

Parameters

Copied!
nametypedescriptiondefaultoptional
labelstringThe type of event (i.e. click, share, search, etc.)-
contentstring or objectThe content the engagement related to, either as an ID or content object.-
scorestringA score between 0 and 100 indicating the importance of an event.-
positionstringThe placement in a list of activities, starting at 0.-
feed_idstringThe specific feed the user is viewing-
locationstringThe page in your app (i.e. email, homepage, profile page, etc.)-