or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-sdk.mdin-app-messages.mdindex.mdlive-activities.mdlocation.mdnotifications.mdpush-subscription.mdsession.mduser-management.md

session.mddocs/

0

# Session Analytics

1

2

Outcome tracking and attribution for measuring notification effectiveness and user engagement.

3

4

## Capabilities

5

6

### Outcome Tracking

7

8

Track user actions and conversions that result from notifications and in-app messages to measure campaign effectiveness.

9

10

```typescript { .api }

11

/**

12

* Increases the "Count" of this Outcome by 1 and will be counted each time sent.

13

* @param name - The name/identifier of the outcome event

14

*/

15

function addOutcome(name: string): void;

16

17

/**

18

* Increases "Count" by 1 only once. This can only be attributed to a single notification.

19

* @param name - The name/identifier of the unique outcome event

20

*/

21

function addUniqueOutcome(name: string): void;

22

23

/**

24

* Increases the "Count" of this Outcome by 1 and the "Sum" by the value. Will be counted each time sent.

25

* If the method is called outside of an attribution window, it will be unattributed until a new session occurs.

26

* @param name - The name/identifier of the outcome event

27

* @param value - The numeric value to add to the outcome sum

28

*/

29

function addOutcomeWithValue(name: string, value: string | number): void;

30

```

31

32

**Usage Examples:**

33

34

```typescript

35

import { OneSignal } from "react-native-onesignal";

36

37

// Track basic outcomes (can be triggered multiple times)

38

OneSignal.Session.addOutcome("button_clicked");

39

OneSignal.Session.addOutcome("page_viewed");

40

OneSignal.Session.addOutcome("video_played");

41

42

// Track unique outcomes (only counted once per notification)

43

OneSignal.Session.addUniqueOutcome("app_opened");

44

OneSignal.Session.addUniqueOutcome("tutorial_completed");

45

OneSignal.Session.addUniqueOutcome("first_purchase");

46

47

// Track outcomes with monetary value

48

OneSignal.Session.addOutcomeWithValue("purchase", 29.99);

49

OneSignal.Session.addOutcomeWithValue("subscription", "15.99");

50

OneSignal.Session.addOutcomeWithValue("tip_given", 5);

51

```

52

53

## Common Use Cases

54

55

### E-commerce Tracking

56

57

```typescript

58

// Track shopping funnel outcomes

59

function trackEcommerceOutcomes() {

60

// User views product (can happen multiple times)

61

OneSignal.Session.addOutcome("product_viewed");

62

63

// User adds to cart (track each add)

64

OneSignal.Session.addOutcome("item_added_to_cart");

65

66

// User starts checkout (unique per session)

67

OneSignal.Session.addUniqueOutcome("checkout_started");

68

69

// Track purchase with value

70

OneSignal.Session.addOutcomeWithValue("purchase_completed", orderTotal);

71

72

// Track specific product category purchases

73

OneSignal.Session.addOutcome("electronics_purchase");

74

}

75

```

76

77

### Content App Tracking

78

79

```typescript

80

// Track content engagement outcomes

81

function trackContentEngagement() {

82

// Article opened (can be multiple per session)

83

OneSignal.Session.addOutcome("article_opened");

84

85

// Video played (track each play)

86

OneSignal.Session.addOutcome("video_played");

87

88

// User subscribes (unique outcome)

89

OneSignal.Session.addUniqueOutcome("subscription_started");

90

91

// Premium upgrade with value

92

OneSignal.Session.addOutcomeWithValue("premium_upgrade", 9.99);

93

94

// Track content sharing

95

OneSignal.Session.addOutcome("content_shared");

96

}

97

```

98

99

### Gaming App Tracking

100

101

```typescript

102

// Track gaming outcomes and monetization

103

function trackGamingOutcomes() {

104

// Level completed (can happen multiple times)

105

OneSignal.Session.addOutcome("level_completed");

106

107

// Achievement unlocked (track each achievement)

108

OneSignal.Session.addOutcome("achievement_unlocked");

109

110

// First game played (unique)

111

OneSignal.Session.addUniqueOutcome("first_game_played");

112

113

// In-app purchases with value

114

OneSignal.Session.addOutcomeWithValue("coins_purchased", 4.99);

115

OneSignal.Session.addOutcomeWithValue("power_up_purchased", 1.99);

116

117

// Daily login bonus claimed

118

OneSignal.Session.addOutcome("daily_bonus_claimed");

119

}

120

```

121

122

### Social App Tracking

123

124

```typescript

125

// Track social engagement outcomes

126

function trackSocialEngagement() {

127

// Post created (can be multiple)

128

OneSignal.Session.addOutcome("post_created");

129

130

// Profile completed (unique setup)

131

OneSignal.Session.addUniqueOutcome("profile_completed");

132

133

// Friend added (track each connection)

134

OneSignal.Session.addOutcome("friend_added");

135

136

// Message sent (track engagement)

137

OneSignal.Session.addOutcome("message_sent");

138

139

// Premium membership (with value)

140

OneSignal.Session.addOutcomeWithValue("premium_membership", 19.99);

141

}

142

```

143

144

### Financial App Tracking

145

146

```typescript

147

// Track financial app outcomes

148

function trackFinancialOutcomes() {

149

// Account created (unique)

150

OneSignal.Session.addUniqueOutcome("account_created");

151

152

// Transaction completed (can be multiple)

153

OneSignal.Session.addOutcome("transaction_completed");

154

155

// Money transferred with value

156

OneSignal.Session.addOutcomeWithValue("money_transferred", transferAmount);

157

158

// Investment made with value

159

OneSignal.Session.addOutcomeWithValue("investment_made", investmentAmount);

160

161

// Feature usage tracking

162

OneSignal.Session.addOutcome("budget_tool_used");

163

OneSignal.Session.addOutcome("savings_goal_set");

164

}

165

```

166

167

## Attribution Windows

168

169

Outcomes are attributed to notifications within specific time windows:

170

171

```typescript

172

// Best practices for outcome timing

173

function handleNotificationClick(notification) {

174

// Immediate outcomes - track right after notification interaction

175

OneSignal.Session.addOutcome("notification_clicked");

176

177

// Delayed outcomes - track when user actually completes action

178

setTimeout(() => {

179

OneSignal.Session.addOutcome("delayed_action_completed");

180

}, 5000);

181

}

182

183

// Track outcomes at appropriate times

184

function trackUserJourney() {

185

// Track at key conversion points

186

onAppOpen(() => {

187

OneSignal.Session.addUniqueOutcome("app_opened");

188

});

189

190

onPurchaseComplete((amount) => {

191

OneSignal.Session.addOutcomeWithValue("purchase", amount);

192

});

193

194

onFeatureUsed((featureName) => {

195

OneSignal.Session.addOutcome(`${featureName}_used`);

196

});

197

}

198

```

199

200

## Outcome Analytics Dashboard

201

202

These outcomes can be viewed in your OneSignal dashboard:

203

204

- **Count**: How many times the outcome occurred

205

- **Sum**: Total value across all outcome events (for `addOutcomeWithValue`)

206

- **Attribution**: Which notifications drove these outcomes

207

- **Conversion Rates**: Percentage of notification recipients who completed outcomes

208

209

```typescript

210

// Structure outcome names for easy dashboard filtering

211

function useStructuredOutcomeNames() {

212

// Category-based naming

213

OneSignal.Session.addOutcome("ecommerce.purchase");

214

OneSignal.Session.addOutcome("ecommerce.cart_abandon");

215

OneSignal.Session.addOutcome("content.article_read");

216

OneSignal.Session.addOutcome("social.post_shared");

217

218

// Action-based naming

219

OneSignal.Session.addOutcome("user_action.login");

220

OneSignal.Session.addOutcome("user_action.logout");

221

OneSignal.Session.addOutcome("user_action.profile_update");

222

}

223

```

224

225

## Value Tracking Best Practices

226

227

```typescript

228

// Always use numeric values for value-based outcomes

229

function trackValueOutcomes() {

230

// GOOD - numeric values

231

OneSignal.Session.addOutcomeWithValue("purchase", 25.99);

232

OneSignal.Session.addOutcomeWithValue("tip", 5);

233

OneSignal.Session.addOutcomeWithValue("subscription", 9.99);

234

235

// Convert strings to numbers when needed

236

const priceString = "15.99";

237

OneSignal.Session.addOutcomeWithValue("upgrade", parseFloat(priceString));

238

239

// Handle different currencies by converting to base unit

240

const priceInCents = Math.round(29.99 * 100); // Convert to cents

241

OneSignal.Session.addOutcomeWithValue("purchase_cents", priceInCents);

242

}

243

```