What is @algolia/client-insights?
@algolia/client-insights is an npm package that allows developers to send events to Algolia's Insights API. This is useful for tracking user interactions with search results, which can then be used to improve search relevance and user experience.
What are @algolia/client-insights's main functionalities?
Initialize the Insights Client
This feature allows you to initialize the Insights client with your Algolia application ID and API key. This is the first step in using the client to send events.
const { createInsightsClient } = require('@algolia/client-insights');
const insightsClient = createInsightsClient({
appId: 'YourApplicationID',
apiKey: 'YourSearchOnlyAPIKey'
});
Send Click Event
This feature allows you to send a click event to the Algolia Insights API. You specify the event type, name, index, user token, and object IDs that were clicked.
insightsClient.sendEvent({
eventType: 'click',
eventName: 'Product Clicked',
index: 'your_index_name',
userToken: 'user-123',
objectIDs: ['objectID1']
});
Send Conversion Event
This feature allows you to send a conversion event, such as a purchase, to the Algolia Insights API. Similar to click events, you specify the event type, name, index, user token, and object IDs involved in the conversion.
insightsClient.sendEvent({
eventType: 'conversion',
eventName: 'Product Purchased',
index: 'your_index_name',
userToken: 'user-123',
objectIDs: ['objectID1']
});
Send View Event
This feature allows you to send a view event to the Algolia Insights API. This is useful for tracking when a user views a product or item in your application.
insightsClient.sendEvent({
eventType: 'view',
eventName: 'Product Viewed',
index: 'your_index_name',
userToken: 'user-123',
objectIDs: ['objectID1']
});
Other packages similar to @algolia/client-insights
segment
Segment is a customer data platform that collects, cleans, and controls customer data. It offers similar functionality to @algolia/client-insights in terms of tracking user interactions and sending events, but it is more comprehensive, supporting a wide range of integrations and data sources.
mixpanel
Mixpanel is an analytics platform that helps businesses understand how users interact with their products. Like @algolia/client-insights, it allows for event tracking, but it also provides advanced analytics and reporting features.
The perfect starting point to integrate Algolia within your JavaScript project
Documentation •
InstantSearch •
Community Forum •
Stack Overflow •
Report a bug •
FAQ •
Support
✨ Features
- Thin & minimal low-level HTTP client to interact with Algolia's API
- Works both on the browser and node.js
- UMD and ESM compatible, you can use it with any module loader
- Built with TypeScript
💡 Getting Started
[!TIP]
This API client is already a dependency of the algoliasearch client, you don't need to manually install @algolia/client-insights
if you already have algoliasearch
installed.
To get started, you first need to install @algolia/client-insights (or any other available API client package).
All of our clients comes with type definition, and are available for both browser and node environments.
With a package manager
yarn add @algolia/client-insights@5.12.0
npm install @algolia/client-insights@5.12.0
pnpm add @algolia/client-insights@5.12.0
Without a package manager
Add the following JavaScript snippet to the of your website:
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.12.0/dist/builds/browser.umd.js"></script>
Usage
You can now import the Algolia API client in your project and play with it.
import { insightsClient } from '@algolia/client-insights';
const client = insightsClient('YOUR_APP_ID', 'YOUR_API_KEY');
For full documentation, visit the Algolia JavaScript API Client.
❓ Troubleshooting
Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client. You can also open a GitHub issue
📄 License
The Algolia JavaScript API Client is an open-sourced software licensed under the MIT license.