Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.32 KB

Readme.md

File metadata and controls

65 lines (46 loc) · 1.32 KB

Customer.io Data Pipelines analytics client for Go.

Installation

go get github.com/customerio/cdp-analytics-go

Usage

package main

import (
    "os"

    "github.com/customerio/cdp-analytics-go"
)

func main() {
    client := analytics.New(os.Getenv("WRITE_KEY"))

    // Enqueues a track event that will be sent asynchronously.
    client.Enqueue(analytics.Track{
        UserId: "4",
        Event:  "order_complete",
    })

    // Flushes any queued messages and closes the client.
    client.Close()
}

Other Regions

If you're using a different data center such as our EU region, you can specify an alternate endpoint:

package main

import (
    "os"

    "github.com/customerio/cdp-analytics-go"
)

func main() {
    client, err := analytics.NewWithConfig(os.Getenv("WRITE_KEY"), analytics.Config{
        Endpoint: "https://cdp-eu.customer.io",
    })
    if err != nil {
        panic(err)
    }

    // ...
}

Documentation

The links below contain more detailed documentation on how to use this library: