Go SDK

Track your data via the Go SDK for Vemetric.


Below you can see how to initialize and configure the SDK, as well as all the available functions.

The Go SDK doesn’t track your page visitors and is meant as a complement to the Frontend SDKs.

Installation

Install the SDK

In your project directory, run:

go get github.com/vemetric/vemetric-go

Initialize the Vemetric Client

We recommend creating a single instance of the Vemetric client and reusing it throughout your application.

import (
  "github.com/Vemetric/vemetric-go"
)

client, err := vemetric.New(&vemetric.Opts{
  Token: "YOUR_PROJECT_TOKEN",
})

Replace YOUR_PROJECT_TOKEN with the unique token for your project (found in the project settings).

If you’re using a proxy to track data via your own domain, you can pass the host option to the client with e.g. https://hub.yourdomain.com.

Methods

Below you can find all the available methods and their functionality.

trackEvent

The main method to track any kind of event.

err = client.TrackEvent(&vemetric.TrackEventOpts{
  EventName: "SignupCompleted",
  UserIdentifier: "user-id",
  EventData: map[string]any{
    "key": "value",
  },
})

You need to pass an vemetric.TrackEventOpts object with the following properties:

  • EventName: Required: The name of the event to track.
  • UserIdentifier: Required: The identifier of the user to associate the event with.
  • EventData: Optional: An object containing the meta data of the event so you can later filter by
  • UserData: Optional: An object to update the user data.
    • Set: An object containing the user data to set, overriding existing values.
    • SetOnce: An object containing the user data to set once, only if the keys do not exist yet.
    • Unset: An array of keys to remove from the user data.

Checkout the tracking custom events section to learn more.

updateUser

Updates the data of the user with the given identifier.

err = client.UpdateUser(&vemetric.UpdateUserOpts{
  UserIdentifier: "user-id",
  UserData: vemetric.UserData{
    Set: map[string]any{"key1": "value1"},
    SetOnce: map[string]any{"key2": "value2"},
    Unset: []string{"key3"},
  },
})

You need to pass an vemetric.UpdateUserOpts object with the following properties:

  • UserIdentifier: Required: The identifier of the user to associate the event with.
  • UserData: An object to update the user data.
    • Set: An object containing the user data to set, overriding existing values.
    • SetOnce: An object containing the user data to set once, only if the keys do not exist yet.
    • Unset: An array of keys to remove from the user data.

Resources

View the Package of the Go SDK.

View the source code of the Go SDK on GitHub.

Track your data via the Python SDK for Vemetric.

Pricing About Documentation Changelog Blog