If your event requests are failing, you can use the Events Debugger to find out why. The most common error code is 422, and you can find these in the debugger in either of the following ways:
- Type
httpCode=422
in the search box to show only the events with the HTTP status code 422 - Select Event Validity > False in the Filter Events button to show all events where
errors=true
We can find a detailed guide on investigating if your click & conversion events are valid here.
Below you can find a list of the most commonly seen errors and how to fix them:
The index field is required
An index must be declared in order for events to be valid. This must be same as the index name used by the search engine.
Cannot process more that 20 objects in an event
You can include up to 20 objectIDs in a single event. You can read more on this here.
Missing userToken parameter
User tokens are strings that uniquely identify users throughout your app. The Search Insights library sets a default anonymous userToken. You can also manually set the userToken or authenticatedUserToken parameter in two ways: either globally or for each event. You can read more about sending userTokens here.
Event of type click should have the same number of ObjectIDs and Positions
When sending click events with a queryID, you must pass an array of positions as the value for the positions parameter with one position per objectID. Algolia uses the positions parameter to calculate the average click position. We have another guide article on this here.
Events should specify either some objectIDs or some Filters
Events are not being processed due to events not specifying objectIDs or filters. In order for conversion events to be valid, they must contain either an objectIDs OR a filters parameter. A single event must not include both objectIDs and filters.
Only event of type click should specify the positions attribute
The positions parameter is only required for click events with a queryID and not view or conversion events.
Invalid eventName syntax
Event names need to be between 1 and 64 characters long and contain only visible ascii characters. You can read more on the eventName parameter here.
Invalid type for field [parameter]: expected string, got number
The specified field holds the wrong value type, for example, it holds an integer while it should hold a string value. A list of the value types each parameter should hold can be found here.
QueryID must be a search queryID
Algolia uses the queryID to connect a search or browse request to a click or conversion event and therefore the queryID sent with an event must match that generated for the corresponding search/browse request. You can read more on sending queryIDs here.
Conversion event must include eventSubtype
Conversion events must include an eventSubtype parameter, You will need to ensure you are sending valid subtypes for all conversion events - either addToCart or purchase. For all other events it should be omitted.
The timestamp must be at most 4 days in the past
The timestamp must be at most 4 days in the past - if you’re doing backend search, it’s important to set correct timestamps.
UserToken must contain only alphanumeric, equal, plus, slash, hyphen or underscore characters
User tokens are strings that uniquely identify users throughout your app. You can read more about them here.
Price must be a valid decimal number and total length must be no longer than 16 characters
Price must be a decimal number with no more than 16 characters (including non-digit characters).
Event of type click with positions should specify a queryID
When sending click events with positions, you must also send a queryID.
Event of type click may only have strictly positive positions
Positions values must start with a 1 and not 0. The first search result has a position of 1 (not 0). The position is absolute, and not relative, to any results page. For example, if there are 10 results per page, the position of the third record of the second results page is 13. Since page
starts at 0, you can use the following formula:$positionOnPage + $page * hitsPerPage
.
Invalid Payload
If you are getting an "invalid payload" error when sending events to the Insights API, we would recommend reviewing your event data parameters to make sure they are in the expected format. We have another guide article on this here.
Events are being sent without a queryID.
While these instances do not raise errors, it will create issues should you wish to use features such as Dynamic Re-Ranking or Analytics as Algolia uses the queryID to connect a search or browse request to a click or conversion event. You can find more info on keeping track of queryIDs here.