What is @algolia/client-personalization?
@algolia/client-personalization is an npm package that provides tools to personalize search and discovery experiences using Algolia's Personalization API. It allows developers to create and manage personalization strategies, user profiles, and events to tailor search results based on user behavior and preferences.
What are @algolia/client-personalization's main functionalities?
Create Personalization Strategy
This feature allows you to create and set a personalization strategy. The strategy includes scoring for different events and facets, which helps in tailoring search results based on user interactions.
const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const personalization = client.initPersonalization();
const strategy = {
eventsScoring: {
'view': { score: 1 },
'click': { score: 2 }
},
facetsScoring: {
'brand': { score: 1 }
}
};
personalization.setPersonalizationStrategy(strategy).then(() => {
console.log('Personalization strategy set successfully');
}).catch(err => {
console.error('Error setting personalization strategy:', err);
});
Get Personalization Strategy
This feature allows you to retrieve the current personalization strategy. It helps in understanding the existing configuration and making necessary adjustments.
const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const personalization = client.initPersonalization();
personalization.getPersonalizationStrategy().then(strategy => {
console.log('Current personalization strategy:', strategy);
}).catch(err => {
console.error('Error getting personalization strategy:', err);
});
Send User Event
This feature allows you to send user events to Algolia. These events are used to track user interactions and improve the personalization of search results.
const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const personalization = client.initPersonalization();
const event = {
eventType: 'click',
eventName: 'product_clicked',
index: 'your_index_name',
userToken: 'user_123',
timestamp: Date.now()
};
personalization.sendEvent(event).then(() => {
console.log('Event sent successfully');
}).catch(err => {
console.error('Error sending event:', err);
});
Other packages similar to @algolia/client-personalization
segment
Segment is a customer data platform that helps you collect, clean, and control your customer data. It provides similar functionalities to @algolia/client-personalization by allowing you to track user events and create personalized experiences. However, Segment offers a broader range of integrations and data management capabilities.
mixpanel
Mixpanel is an analytics platform that helps you understand how users interact with your product. It offers event tracking and user profile management similar to @algolia/client-personalization. Mixpanel focuses more on analytics and insights, providing advanced tools for user behavior analysis and engagement.
amplitude
Amplitude is a product analytics platform that helps you understand user behavior and optimize your product. It provides event tracking and user segmentation features similar to @algolia/client-personalization. Amplitude is known for its powerful analytics capabilities and detailed user journey tracking.
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-personalization
if you already have algoliasearch
installed.
To get started, you first need to install @algolia/client-personalization (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-personalization@5.6.1
npm install @algolia/client-personalization@5.6.1
pnpm add @algolia/client-personalization@5.6.1
Without a package manager
Add the following JavaScript snippet to the of your website:
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.6.1/dist/builds/browser.umd.js"></script>
Usage
You can now import the Algolia API client in your project and play with it.
import { personalizationClient } from '@algolia/client-personalization';
const client = personalizationClient('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.