Search documentation...

K
ChangelogBook a demoSign up

C# SDK

The C# SDK makes it easy to track events from all C#/.NET applications.

Installation

The C# SDK can be installed from NuGet:

dotnet add package Hightouch.Events.CSharp

To initialize the C# SDK in your application, create a new Analytics instance:

using Hightouch.Events;
using Hightouch.Events.Serialization;

var configuration = new Configuration("WRITE_KEY",
  apiHost: "https://us-east-1.hightouch-events.com",
  flushAt: 1);

var analytics = new Analytics(configuration);

API

Identify

The analytics.Identify method sends an identify event.

Example usage:

analytics.Identify("user-123", new JsonObject {
    ["username"] = "MisterWhiskers",
    ["email"] = "hello@test.com",
    ["plan"] = "premium"
});

Track

The analytics.Track method sends a track event.

Example usage:

analytics.Track("View Product", new JsonObject {
    ["productId"] = 123,
    ["productName"] = "Striped trousers"
});

Page

The analytics.Page method sends a page event.

Example usage:

analytics.Page("PageName", new JsonObject {
    ["productSlug"] = "example-product-123"
});

Screen

The analytics.Screen method sends a screen event.

Example usage:

analytics.Screen("ScreenName", new JsonObject {
    ["productSlug"] = "example-product-123"
});

Group

The analytics.Group method sends a group event.

Example usage:

analytics.Group("user-123", new JsonObject {
    ["username"] = "MisterWhiskers",
    ["email"] = "hello@test.com",
    ["plan"] = "premium"
});

Flush

The C# SDK buffers events locally, either in-memory or on disk, before sending them to Hightouch's servers. This minimizes the number of requests made by the SDK and makes the tracking non-blocking.

To force the local buffer to be sent to Hightouch immediately call the Flush() method. Flush() should be called when shutting down your app to make sure no events are lost.

Example usage:

analytics.Flush()

Ready to get started?

Jump right in or a book a demo. Your first destination is always free.

Book a demoSign upBook a demo

Need help?

Our team is relentlessly focused on your success. Don't hesitate to reach out!

Feature requests?

We'd love to hear your suggestions for integrations and other features.

Last updated: Aug 20, 2024

On this page

InstallationAPIIdentifyTrackPageScreenGroupFlush

Was this page helpful?