> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Purchased object IDs after search

> Send a conversion event related to an Algolia request to capture when users purchase items.

**Required ACL:** `search`

Use this event to track when users make a purchase after a previous Algolia request.

If you use Algolia to build your [category pages](/doc/guides/solutions/ecommerce/browse/tutorials/category-pages),
you'll also use the `purchasedObjectIDsAfterSearch` event.

For details, which Algolia features use this event, see [Event types](/doc/guides/sending-events/concepts/event-types).

**Related methods:**

* [`purchasedObjectIDs`](/doc/libraries/search-insights/purchased-object-ids): track *Purchase* events **not related to Algolia requests**.
* [`addedToCartObjectIDsAfterSearch`](/doc/libraries/search-insights/purchased-object-ids-after-search): track *Add to cart* events.
* [`convertedObjectIDsAfterSearch`](/doc/libraries/search-insights/converted-object-ids): track other conversion events.
* [`sendEvents`](/doc/libraries/search-insights/send-events): if you don't want to send real-time events.

## Examples

For more information about initializing the JavaScript Insights client `aa`,
see [Initialize the Insights client](/doc/libraries/search-insights/init).

```js JavaScript icon=code theme={"system"}
aa("purchasedObjectIDsAfterSearch", {
  userToken: "anonymous-123456", // required for Node.js
  authenticatedUserToken: "user-123456",
  eventName: "your_event_name",
  index: "INDEX_NAME",
  objectIDs: ["objectID-1", "objectID-2"],
  objectData: [
    {
      queryID: "queryID-1",
      price: 19.99,
      discount: 3.99,
      quantity: 3,
    }, // This item was purchased as the result of a query
    {
      price: 59.99,
      discount: 10,
      quantity: 2,
    }, // This item isn't associated with a query and won't be included in revenue analytics
  ],
  value: 179.95,
  currency: "USD",
});
```

<Info>
  Some purchase event objects may be associated with a query, while others may not.
  Only objects with a `queryID` are included in revenue analytics.
  For more information, see [Revenue transactions](/doc/guides/search-analytics/concepts/query-aggregation#revenue-transactions).
</Info>

## Parameters

<ParamField body="eventName" type="string" required>
  Name of the specific event.

  **Format:** 1-64 ASCII characters, except control characters.

  To maximize the impact of your events,
  use consistent event names and consistent formatting,
  for example, "Product Added To Cart" (always in title case).

  For example, you can adopt Twilio Segment's [object-action framework](https://segment.com/academy/collecting-data/naming-conventions-for-clean-data/#the-object-action-framework).
</ParamField>

<ParamField body="indexName" type="string" required>
  Name of the Algolia index.

  **Format**: same as the index name used by the search engine.

  Some API clients use `index` instead of `indexName`.
</ParamField>

<ParamField body="objectIDs" type="string[]" required>
  List of object IDs for items of an Algolia index.

  You can include up to 20 `objectID`.
</ParamField>

<ParamField body="userToken" type="string" required>
  Anonymous user identifier.

  See also: [User token](/doc/guides/sending-events/concepts/usertoken)
</ParamField>

<ParamField body="authenticatedUserToken" type="string">
  Pseudonymous identifier for authenticated users.

  <Warning>
    Don't include personally identifiable information in user tokens.
  </Warning>

  See also: [User token](/doc/guides/sending-events/concepts/usertoken)
</ParamField>

<ParamField body="currency" type="string">
  If you include pricing information in the `objectData` parameter or provide `value`,
  you must also specify the currency as ISO-4217 currency code,
  such as USD or EUR.
</ParamField>

<ParamField body="discount" type="number | string">
  Absolute value of the discount in effect for this object, measured in
  `currency`.

  Must be a decimal number with no more than 16 characters (including non-digit characters).
</ParamField>

<ParamField body="objectData" type="object[]">
  Extra information about the records involved in the event,
  for example, price and quantities of purchased products.

  If provided, must be the same length as `objectIDs`.

  If you include pricing information, you must also specify the `currency` parameter.
</ParamField>

<ParamField body="price" type="number | string">
  The price of the item.
  This should be the final price, including any discounts.

  Must be a decimal number with no more than 16 characters (including non-digit characters).
</ParamField>

<ParamField body="quantity" type="number">
  The quantity of the purchased or added-to-cart item.
  The total value of a purchase is the sum of `quantity` multiplied by the
  `price` of each purchased item.
</ParamField>

<ParamField body="queryID" type="string">
  ID of the query that this specific record is attributable to. Used
  to track purchase events with multiple items originating from different searches.

  Objects without a query ID aren't included in revenue analytics.
  For more information, see [Revenue transactions](/doc/guides/search-analytics/concepts/query-aggregation#revenue-transactions).

  See also: [Keep track of query IDs](/doc/guides/sending-events/guides/queryid)
</ParamField>

<ParamField body="value" type="number | string">
  The monetary value of the event, measured in `currency`.
  For example, the total value of a purchase.

  If you assign a `value`, you must also specify the `currency` parameter.

  Must be a decimal number with no more than 16 characters (including non-digit characters).
</ParamField>
