Skip to main content
Required ACL: search You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.

Usage

// Initialize the client
var client = new InsightsClient(
  new InsightsConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);

// Call the API
var response = await client.PushEventsAsync(
  new InsightsEvents
  {
    Events = new List<EventsItems>
    {
      new EventsItems(
        new ClickedObjectIDsAfterSearch
        {
          EventType = Enum.Parse<ClickEvent>("Click"),
          EventName = "Product Clicked",
          Index = "products",
          UserToken = "user-123456",
          AuthenticatedUserToken = "user-123456",
          Timestamp = 1641290601962L,
          ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
          QueryID = "43b15df305339e827f0ac0bdc5ebcaa7",
          Positions = new List<int> { 7, 6 },
        }
      ),
    },
  }
);

// print the response
Console.WriteLine(response);
// Initialize the client
final client = InsightsClient(
    appId: 'ALGOLIA_APPLICATION_ID',
    apiKey: 'ALGOLIA_API_KEY',
    region: 'ALGOLIA_APPLICATION_REGION');

// Call the API
final response = await client.pushEvents(
  insightsEvents: InsightsEvents(
    events: [
      ClickedObjectIDsAfterSearch(
        eventType: ClickEvent.fromJson("click"),
        eventName: "Product Clicked",
        index: "products",
        userToken: "user-123456",
        authenticatedUserToken: "user-123456",
        timestamp: 1641290601962,
        objectIDs: [
          "9780545139700",
          "9780439784542",
        ],
        queryID: "43b15df305339e827f0ac0bdc5ebcaa7",
        positions: [
          7,
          6,
        ],
      ),
    ],
  ),
);

// print the response
print(response);
// Initialize the client with your application region, eg. insights.ALGOLIA_APPLICATION_REGION
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)
}

// Call the API
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)
}


// print the response
print(response)
// Initialize the client
InsightsClient client = new InsightsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");

// Call the API
EventsResponse response = client.pushEvents(
  new InsightsEvents().setEvents(
    Arrays.asList(
      new ClickedObjectIDsAfterSearch()
        .setEventType(ClickEvent.CLICK)
        .setEventName("Product Clicked")
        .setIndex("products")
        .setUserToken("user-123456")
        .setAuthenticatedUserToken("user-123456")
        .setTimestamp(1641290601962L)
        .setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
        .setQueryID("43b15df305339e827f0ac0bdc5ebcaa7")
        .setPositions(Arrays.asList(7, 6))
    )
  )
);

// print the response
System.out.println(response);
// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initInsights({ region: 'us' });

// Call the API
const response = await client.pushEvents({
  events: [
    {
      eventType: 'click',
      eventName: 'Product Clicked',
      index: 'products',
      userToken: 'user-123456',
      authenticatedUserToken: 'user-123456',
      timestamp: 1641290601962,
      objectIDs: ['9780545139700', '9780439784542'],
      queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
      positions: [7, 6],
    },
  ],
});


// print the response
console.log(response);
// Initialize the client
val client =
  InsightsClient(
    appId = "ALGOLIA_APPLICATION_ID",
    apiKey = "ALGOLIA_API_KEY",
    region = "ALGOLIA_APPLICATION_REGION",
  )

// Call the API
var response =
  client.pushEvents(
    insightsEvents =
      InsightsEvents(
        events =
          listOf(
            ClickedObjectIDsAfterSearch(
              eventType = ClickEvent.entries.first { it.value == "click" },
              eventName = "Product Clicked",
              index = "products",
              userToken = "user-123456",
              authenticatedUserToken = "user-123456",
              timestamp = 1641290601962L,
              objectIDs = listOf("9780545139700", "9780439784542"),
              queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
              positions = listOf(7, 6),
            )
          )
      )
  )


// print the response
println(response)
// Initialize the client
$client = InsightsClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');

// Call the API
$response = $client->pushEvents(
    ['events' => [
        ['eventType' => 'click',
            'eventName' => 'Product Clicked',
            'index' => 'products',
            'userToken' => 'user-123456',
            'authenticatedUserToken' => 'user-123456',
            'timestamp' => 1641290601962,
            'objectIDs' => [
                '9780545139700',

                '9780439784542',
            ],
            'queryID' => '43b15df305339e827f0ac0bdc5ebcaa7',
            'positions' => [
                7,

                6,
            ],
        ],
    ],
    ],
);


// print the response
var_dump($response);
# Initialize the client
# In an asynchronous context, you can use InsightsClient instead, which exposes the exact same methods.
client = InsightsClientSync(
    "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)

# Call the API
response = client.push_events(
    insights_events={
        "events": [
            {
                "eventType": "click",
                "eventName": "Product Clicked",
                "index": "products",
                "userToken": "user-123456",
                "authenticatedUserToken": "user-123456",
                "timestamp": 1641290601962,
                "objectIDs": [
                    "9780545139700",
                    "9780439784542",
                ],
                "queryID": "43b15df305339e827f0ac0bdc5ebcaa7",
                "positions": [
                    7,
                    6,
                ],
            },
        ],
    },
)


# print the response
print(response)
# Initialize the client
client = Algolia::InsightsClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")

# Call the API
response = client.push_events(
  Algolia::Insights::InsightsEvents.new(
    events: [
      Algolia::Insights::ClickedObjectIDsAfterSearch.new(
        event_type: "click",
        event_name: "Product Clicked",
        index: "products",
        user_token: "user-123456",
        authenticated_user_token: "user-123456",
        timestamp: 1641290601962,
        object_ids: ["9780545139700", "9780439784542"],
        query_id: "43b15df305339e827f0ac0bdc5ebcaa7",
        positions: [7, 6]
      )
    ]
  )
)


# print the response
puts(response)
// Initialize the client
val client = InsightsClient(
  appId = "ALGOLIA_APPLICATION_ID",
  apiKey = "ALGOLIA_API_KEY",
  region = Option("ALGOLIA_APPLICATION_REGION")
)

// Call the API
val response = Await.result(
  client.pushEvents(
    insightsEvents = InsightsEvents(
      events = Seq(
        ClickedObjectIDsAfterSearch(
          eventType = ClickEvent.withName("click"),
          eventName = "Product Clicked",
          index = "products",
          userToken = "user-123456",
          authenticatedUserToken = Some("user-123456"),
          timestamp = Some(1641290601962L),
          objectIDs = Seq("9780545139700", "9780439784542"),
          queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
          positions = Seq(7, 6)
        )
      )
    )
  ),
  Duration(100, "sec")
)

// print the response
println(response)
// Initialize the client
let client = try InsightsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)

// Call the API
let response = try await client
    .pushEvents(insightsEvents: InsightsEvents(events: [EventsItems
            .clickedObjectIDsAfterSearch(ClickedObjectIDsAfterSearch(
                eventName: "Product Clicked",
                eventType: ClickEvent.click,
                index: "products",
                objectIDs: ["9780545139700", "9780439784542"],
                positions: [7, 6],
                queryID: "43b15df305339e827f0ac0bdc5ebcaa7",
                userToken: "user-123456",
                authenticatedUserToken: "user-123456",
                timestamp: Int64(1_641_290_601_962)
            ))]))

// print the response
print(response)

See the full API reference

For more details about input parameters and response fields.
Last modified on March 25, 2026