Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
85
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-personalization

JavaScript client for client-personalization

  • 5.7.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
85
Created

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

FAQs

Package last updated on 01 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc