Please reach out to MetaRouter before testing or implementing this library.


This library lets you record analytics data from your ASP.NET, C#, F#, and Visual Basic code. Once installed, the requests will be sent to the MetaRouter platform and then sent to the integrations you have configured for your pipeline that is connected to your .NET events.

You can use the .NET library in your web server controller code. It is built for high performance and uses and internal queue to make all calls non-blocking and fast. It will batch messages and flush asynchronously to the MetaRouter platform.

Install Analytics.js

You must install our client-side library, Analytics.js, to your ASP.NET master page. Follow the steps outlined in our Analytics.js install guide and place your snippet directly in your ASP.NET Site.master. This will allow you to use page calls.

Install the .NET Library

Next, you will install our .NET library using the identify and track calls. We recommend using NuGet to do this.

Install-Package Analytics

You can also doing this by navigating through Visual Studio: Tools > Library Package Manager > Package Manager Console

Initialize the Library

Now you need to initialize the .NET library so that it knows where to send data. Do this with your pipeline's writeKey. Once this is completed, you can use the Analytics singleton in any controller you would like:

<%@ Application Language="C#" %>
<%@ Import Namespace="ASP.NET_Example" %>
<%@ Import Namespace="System.Web.Optimization" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="Astronomer" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e)
        Astronomer.Analytics.Initialize("YOUR_WRITEKEY", new Config()


Now, initialize the project:


You will only need to perform this initialization once.

Required SDK Edits

In the above SDK, you will need to include your custom Host URL. Instructions for setting up your DNS, which includes the Host URL that you will insert into your SDK setup, can be found here. Your writeKey will indicate the specific pipeline you would like to feed your events into.

Event Methods in .NET

Check out the below event methods and their use cases to determine the events that you need to trigger. We have included examples of how you would call specific objects in .NET. More information on event methods can be found here.


The identify method helps you associate your users and their actions to a unique and recognizable userID and any optional traits that you know about them. We recommend calling an identify a single time - when the user's account is first created and only again when their traits change.

Analytics.Client.Identify("YOUR_WRITEKEY", new Traits() {
    { "name", "#{ }" },
    { "email", "#{ }" },
    { "fingers", 10 }


To get to a more complete event tracking analytics setup, you can add a track call to your website. This will tell MetaRouter which actions you are performing on your site. With track, each user action triggers an “event,” which can also have associated properties.

Analytics.Client.Track("YOUR_WRITEKEY", "Add to Cart", new Properties() {
    { "price", 50.00 },
    { "size", "Medium" }


The page method allows you to record page views on your website. It also allows you to pass additional information about the pages people are viewing.

Analytics.Client.Page("YOUR_WRITEKEY", "Login", new Properties() {
    { "path", "/login" },
    { "title", "MetaRouter Login" }


Analytics.Client.Group("userId", "groupId", new Traits() {
    { "name", "MetaRouter" },
    { "website", "" }

The group method associates an identified user with a company, organization, project, etc.