Collecting data with Trackers and Webhooks

  1. Home
  2. Docs
  3. Collecting data with Trackers and Webhooks
  4. Trackers – collecting data from your own applications
  5. .NET Tracker
  6. Subject

Subject

You may have additional information about your application’s environment, current user and so on, which you want to send to Snowplow with each event.

The Subject class has a set of Set...() methods to attach extra data relating to the user to all tracked events:

Here are some examples:

Subject s1 = new Subject(); s1.SetUserId("Kevin Gleason"); s1.SetLang("en-gb"); s1.SetScreenResolution(1920, 1080);
Code language: JavaScript (javascript)

SetUserId

You can set the user ID to any string:

s1.SetUserId( "{{USER ID}}" )
Code language: JavaScript (javascript)

Example:

s1.SetUserId("alexd")
Code language: JavaScript (javascript)

SetScreenResolution

If your C# code has access to the device’s screen resolution, then you can pass this in to Snowplow too:

s1.SetScreenResolution( {{WIDTH}}, {{HEIGHT}} )

Both numbers should be positive integers; note the order is width followed by height. Example:

s1.SetScreenResolution(1366, 768)
Code language: CSS (css)

SetViewport

If your C# code has access to the viewport dimensions, then you can pass this in to Snowplow too:

s1.SetViewport( {{WIDTH}}, {{HEIGHT}} )

Both numbers should be positive integers; note the order is width followed by height. Example:

s1.SetViewport(300, 200)
Code language: CSS (css)

SetColorDepth

If your C# code has access to the bit depth of the device’s color palette for displaying images, then you can pass this in to Snowplow too:

s.SetColorDepth( {{BITS PER PIXEL}} )

The number should be a positive integer, in bits per pixel. Example:

s.SetColorDepth(32)
Code language: CSS (css)

SetTimezone

This method lets you pass a user’s timezone in to Snowplow:

s.SetTimezone( {{TIMEZONE}} )

The timezone should be a string:

s.SetTimezone("Europe/London")
Code language: JavaScript (javascript)

SetLang

This method lets you pass a user’s language in to Snowplow:

s.SetLang( {{LANGUAGE}} )

The language should be a string:

s.SetLang('en')
Code language: JavaScript (javascript)

SetIpAddress

This method lets you pass a user’s IP Address in to Snowplow:

s.SetIpAddress( {{IP ADDRESS}} )

The IP address should be a string:

s.SetIpAddress("127.0.0.1");
Code language: CSS (css)

SetUseragent

This method lets you pass a useragent in to Snowplow:

s.SetUseragent( {{USERAGENT}} )

The useragent should be a string:

s.SetUseragent("Agent Smith");
Code language: JavaScript (javascript)

SetNetworkUserId

This method lets you pass a Network User ID in to Snowplow:

s.SetNetworkUserId( {{NUID}} )

The network user id should be a string:

s.SetNetworkUserId("network-id");
Code language: JavaScript (javascript)

SetDomainUserId

This method lets you pass a Domain User ID in to Snowplow:

s.SetDomainUserId( {{DUID}} )

The domain user id should be a string:

s.SetDomainUserId("domain-id");
Code language: JavaScript (javascript)

SetPlatform

This method lets you set the Platform that the Tracker is running on:

s.SetPlatform( Platform.{{ option }} )

The Platform should be an enum:

s.SetPlatform(Platform.Mob);
Code language: CSS (css)

Available platforms:

  • Web
  • Mob
  • Pc
  • Srv
  • App
  • Tv
  • Cnsl
  • Iot

If you’d like to learn more about Snowplow Insights you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.