Skip to content

Commit 3935caa

Browse files
committed
csharp edits
1 parent a0d565e commit 3935caa

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

src/_data/sidenav/strat.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,11 @@ sections:
203203
title: Analytics-Node.js Classic
204204
- path: /connections/sources/catalog/libraries/server/node/migration/
205205
title: Analytics-Node.js Migration Guide
206+
207+
- slug: csharp
208+
section_title: Analytics-CSharp Documentation
209+
section:
210+
- path:
211+
title:
212+
- path:
213+
title:
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Analytics for CSharp (C#)
3+
strat: csharp
4+
---
5+
6+
If you’re using a different library such as Analytics .Net, follow these steps to migrate to the Analytics-CSharp library:
7+
8+
1. Create a source in Segment. If you want to reuse your current source, skip to step 2.
9+
1. Go to Connections > Sources > Add Source.
10+
2. Search for Xamarin or Unity or .NET and click Add source.
11+
2. Add the Analytics CSharp dependency to your project.
12+
13+
<br> Before:
14+
```js
15+
dotnet add package Analytics --version <VERSION>
16+
```
17+
18+
<br>After
19+
```js
20+
dotnet add package Segment.Analytics.CSharp --version <VERSION>
21+
```
22+
23+
3. Modify your tracking methods.
24+
- Identify
25+
26+
<br> Before example
27+
```c#
28+
Analytics.Client.Identify("019mr8mf4r", new Traits() {
29+
{ "name", "#{ user.name }" },
30+
{ "email", "#{ user.email }" },
31+
{ "friends", 29 }
32+
});
33+
```
34+
35+
<br> After example
36+
```c#
37+
// compatbile with the old way
38+
analytics.Identify("019mr8mf4r", new JsonObject()
39+
{
40+
{ "name", "#{ user.name }" },
41+
{ "email", "#{ user.email }" },
42+
{ "friends", 29 }
43+
});
44+
45+
// below is the new way
46+
analytics.Identify("019mr8mf4r", new JsonObject
47+
{
48+
["name"] = "#{user.name}",
49+
["email"] = "#{user.email}",
50+
["friends"] = 29
51+
});
52+
```
53+
54+
- Track
55+
<br> Before example
56+
```c#
57+
Analytics.Client.Track("019mr8mf4r", "Item Purchased", new Properties() {
58+
{ "revenue", 39.95 },
59+
{ "shipping", "2-day" }
60+
});
61+
```
62+
63+
<br> After example
64+
```c#
65+
// compatbile with the old way
66+
analytics.Track("Item Purchased", new JsonObject()
67+
{
68+
{ "revenue", 39.95 },
69+
{ "shipping", "2-day" }
70+
});
71+
72+
// below is the new way
73+
analytics.Track("Item Purchased", new JsonObject
74+
{
75+
["revenue"] = 39.95,
76+
["shipping"] = "2-days"
77+
});
78+
```
79+
**Note:**
80+

0 commit comments

Comments
 (0)