Lumen
Search…
Go
Lumen-go client library allows you to seamlessly identify and track user attributes and events on your app. Plus other perks.

Installation

go get github.com/uselumen/lumen-go
Import the package
import (
"github.com/uselumen/lumen-go"
)

Initialization

Initialize the library with your public key. Any request that doesn't include a valid API key will return an error.
const LumenApiKey = "<< your-api-key >>";
lumen := lumengo.NewLumengo(LumenApiKey)
You can generate an API key from your Dashboard at any time.

Usage

Identify a user

You must identify users with a unique identifier before you can track their events. A new customer record is created if the identifier doesn't exist. If the identifier exists, then the customer record is updated with the new data supplied.
data := lumengo.IdentifyParams{
Email: "[email protected]", // required
FirstName: "Gopher",
LastName: "Basit",
}
err := lumen.Identify("<< user-identifier >>", data);
if err !=nil {
return err
}
Ideally, identify should be called when a user creates a new account. To update an existing user’s records, simply call identify and add any property you want to add or change. If the property already exists, we overwrite them. If it is new, we add them to the user's record.
To ensure your data is in sync with our record, make sure you update your user's records when they change so as to prevent stale data.
You can also manage your user records on the dashboard.

Track an event

After identifying users, you can now capture their actions like "Product Clicked" or "Product Viewed" with other custom properties.
properties := map[string]interface{}{
"productId": 100023449,
}
err := lumen.Track("<< user-identifier >>", "<< event-name >>", params)
if err != nil {
return err
}
Copy link
On this page
Installation
Initialization
Usage