Guides / Getting insights and analytics / Connectors

The Algolia connector for Segment is currently in public beta, and handling e-commerce related events. Please reach out to us at contact@algolia.com if you want to track events we do not support (yet).

Overview

If you already have integrated Segment on your website and are sending events to Segment, you can configure your Segment dashboard to redirect the events to Algolia.

There are two steps to integrate Segment with Algolia:

  1. Enable the “Algolia” destination on your Segment dashboard.
  2. Add extra Algolia-related data to events sent to Segment.

Supported events

Not all events from Segment are redirected to Algolia.

The following events, complying with Segment E-commerce Events Spec v2, are redirected:

Enable “Algolia” destination on your Segment dashboard

On your source, click the “Add Destination” button. 1 sources

From the destination catalog, search for and add “Algolia”. 2 destinations

Once added to your source, click the settings button (the gear icon). 3 added

Copy your Application ID and Search-Only API Key from your Algolia dashboard and paste there. 4 configuration

With Segment integrated, you probably have code that looks something like the following in order to send events to Segment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
analytics.track('Product Clicked', {
  product_id: '507f1f77bcf86cd799439011',
  sku: 'G-32',
  category: 'Games',
  name: 'Monopoly: 3rd Edition',
  brand: 'Hasbro',
  variant: '200 pieces',
  price: 18.99,
  quantity: 1,
  coupon: 'MAYDEALS',
  position: 3,
  url: 'https://www.example.com/product/path',
  image_url: 'https://www.example.com/product/path.jpg'
});

Algolia requires some additional fields that are not a part of the regular Segment E-commerce Events Spec v2. Which fields are required depends on which e-commerce event is being sent. The supported events page indicates which fields are required for each event.

Renaming events

If you’re already sending events which names don’t respect the specification, you need to rename them for them to work with Algolia. If you can’t edit your code directly, you can do it in Segment.

In Segment, go to the destination settings and click Rename Events.

5 destination settings

There, you can set your current event names on the left column, and the new ones on the right.

6 rename events

Using Algolia Personalization with Segment

If you pass a userId to Segment (by using analytics.identify()), you may want to pass the same identifier to Algolia to allow personalized search results. All you need to do is pass the userToken parameter with your search.

1
2
3
4
5
6
index.search('query', {
  userToken: 'user-1',
  enablePersonalization: true
}).then(({ hits }) => {
  console.log(hits);
})

Did you find this page helpful?