Send events

Sends a list of events to the Insights API.

You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import "github.com/algolia/algoliasearch-client-go/v4/algolia/insights"

client, err := insights.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", insights.US)
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.PushEvents(client.NewApiPushEventsRequest(

  insights.NewEmptyInsightsEvents().SetEvents(
    []insights.EventsItems{*insights.ClickedObjectIDsAfterSearchAsEventsItems(
      insights.NewEmptyClickedObjectIDsAfterSearch().SetEventType(insights.ClickEvent("click")).SetEventName("Product Clicked").SetIndex("products").SetUserToken("user-123456").SetAuthenticatedUserToken("user-123456").SetTimestamp(1641290601962).SetObjectIDs(
        []string{"9780545139700", "9780439784542"}).SetQueryID("43b15df305339e827f0ac0bdc5ebcaa7").SetPositions(
        []int32{7, 6}))})))
if err != nil {
  // handle the eventual error
  panic(err)
}
Did you find this page helpful?
Go API clients v4