Skip to content

Tracking Developer Overview

In this article we look at Bizzkit Tracking from a developer's perspective and provide a tutorial on order tracking using the .NET SDK.

Before getting started

In this concept article you can find an overview of Bizzkit Tracking, including its architecture and event types. If you haven't already, we recommend reading it.

Using the .NET SDK

For easy integration with Microsoft .NET, Bizzkit offers SDK packages. These packages include auto-generated Swagger clients and a factory class to simplify authentication. They automate token renewal and provide type-safe methods for the API endpoints.

All SDK package names start with the prefix Bizzkit.Sdk., and the SDK packages incorporate the following elements:

  • A client factory
  • A dedicated client
  • Options to configure the client factory

Info

Preview versions are identified as Bizzkit.Sdk.[product].Preview, such as Bizzkit.Sdk.Iam.Preview or Bizzkit.Sdk.Pim.Preview.

To access the Bizzkit NuGet packages in your preferred development environment, you need to reference the Bizzkit Partner feed. You can, for example, do this by adding a nuget.config file to your project with the following configuration:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="bizzkit-partner" value="https://pkgs.dev.azure.com/bizzkit-platform/7dad82b4-f2ae-4a3a-ab87-3fc791e4ea62/_packaging/bizzkit-partner-feed/nuget/v3/index.json" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="nuget">
      <package pattern="*" />
    </packageSource>
    <packageSource key="bizzkit-partner">
      <package pattern="Bizzkit*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

This configuration clears existing package sources and adds the Bizzkit Partner feed alongside the official NuGet source.

Once the feed is configured, you can install the required NuGet package using the following command:

dotnet add package Bizzkit.Sdk.EventTracking.EventReceiver

The Event Receiver SDK provides an unauthenticated client — no OAuth token is required. Events are associated with the correct tenant and segment via the instrumentation key included in each request.

using Bizzkit.Sdk.EventTracking.EventReceiver;

var factory = new EventReceiverClientFactory(
    new EventReceiverConnectionOptions
    {
        BaseUrl = "https://myenv-tracking.bizzkit.biz"
    },
    new HttpClient());

var client = await factory.CreateUnauthenticatedClientAsync();

Tutorial: Order tracking

This tutorial demonstrates how to submit an OrderCreated event when a customer completes a purchase in the webshop. The order event includes the order total, currency, and individual line items.

Step 1: Capture the order data

When a customer completes checkout, collect the order details from your commerce system:

var orderId = "ORD-20240315-001";
var orderTotal = 299.98;
var currency = "EUR";
var lineItems = new[]
{
    new OrderLineItemModel
    {
        ProductId = "PROD-001",
        SkuId = "SKU-001-BLK-M",
        Quantity = 2,
        Price = 99.99
    },
    new OrderLineItemModel
    {
        ProductId = "PROD-042",
        SkuId = "SKU-042-WHT-L",
        Quantity = 1,
        Price = 100.00
    }
};

Step 2: Submit the order event

Using the client created above, submit the OrderCreated event:

await client.EventsAsync(new TrackedEventBatchModel
{
    InstrumentationKey = "your-instrumentation-key",
    Events = new[]
    {
        new TrackedEventModel
        {
            EventType = "OrderCreated",
            SessionId = "session-abc-123",
            UserId = "user-456",
            OrderId = orderId,
            OrderTotal = orderTotal,
            Currency = currency,
            LineItems = lineItems
        }
    }
});

Step 3: Verify

The Event Receiver responds with 202 Accepted once the event batch is received. Events are processed asynchronously.

Complete example

Below is the full example combining client creation and order event submission:

using Bizzkit.Sdk.EventTracking.EventReceiver;

// Create the client
var factory = new EventReceiverClientFactory(
    new EventReceiverConnectionOptions
    {
        BaseUrl = "https://myenv-tracking.bizzkit.biz"
    },
    new HttpClient());

var client = await factory.CreateUnauthenticatedClientAsync();

// Submit an order event
await client.EventsAsync(new TrackedEventBatchModel
{
    InstrumentationKey = "your-instrumentation-key",
    Events = new[]
    {
        new TrackedEventModel
        {
            EventType = "OrderCreated",
            SessionId = "session-abc-123",
            UserId = "user-456",
            OrderId = "ORD-20240315-001",
            OrderTotal = 299.98,
            Currency = "EUR",
            LineItems = new[]
            {
                new OrderLineItemModel
                {
                    ProductId = "PROD-001",
                    SkuId = "SKU-001-BLK-M",
                    Quantity = 2,
                    Price = 99.99
                },
                new OrderLineItemModel
                {
                    ProductId = "PROD-042",
                    SkuId = "SKU-042-WHT-L",
                    Quantity = 1,
                    Price = 100.00
                }
            }
        }
    }
});

Console.WriteLine("Order event submitted successfully.");

Warning

Please keep in mind that all examples provided are for illustrative purposes only. They are not intended to represent best practices and should not be used in production without a thorough code review.

Key considerations

  • Batch events — The TrackedEventBatchModel supports multiple events in a single request. Batch related events together when possible to reduce HTTP overhead.
  • Idempotency — Events are processed at-least-once. Design your analytics to be tolerant of duplicate events.
  • Instrumentation key security — Treat instrumentation keys as semi-sensitive. They identify your tenant and segment but do not grant access to stored data.