Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

search-insights

algolia3.5mMIT2.17.3TypeScript support: included

Library for reporting click, conversion and view metrics using the Algolia Insights API

readme

Search Insights

Build Status npm version

Search Insights lets you report click, conversion and view metrics using the Algolia Insights API.

Table of Contents

NOTE: You're looking at the documentation of search-insights v2. (Click here for v1.x documentation.)

Notices

v2 introduces a breaking change which is useCookie being false by default.

Payload validation

Since v2.0.4, search-insights no longer validates event payloads. You can visit https://algolia.com/events/debugger instead.


Getting started

We have created dedicated integrations for Google Tag Manager and Segment. If you are using either of these platforms, it is recommended to use the dedicated integrations to manage sending events to the Insights API.

Browser

For information on how to set up search-insights.js in a browser environment, see our documentation on Installing and Initializing the Insights Client.

We also have documentation for using search-insights.js with InstantSearch and Autocomplete.

NOTE: If you are using Require.js, see our Note for Require.js users.

Node.js

For information on how to set up search-insights.js in a Node.js environment, see our guide on Installing and Initializing the Insights Client for Node.js.

Documentation

Documentation for search-insights.js can be found in our main Algolia Docs website. For API Client reference information, see the Insights API Client Documentation.

Contributing

To run the examples and the code, you need to run two separate commands:

  • yarn dev runs webpack and the Node.js server
  • yarn build:dev runs Rollup in watch mode

Releasing

For information on releasing, see RELEASE.md.

License

Search Insights is MIT licensed.

changelog

2.17.3 (2024-11-05)

Bug Fixes

  • save existing anon tokens for multiple init calls (#562) (86164bb)

2.17.2 (2024-09-11)

Bug Fixes

  • check if localStorage is usable before using it (#558) (eb460a8), closes #556
  • don't store query/object associations when userHasOptedOut is true (#557) (7c4ab3a)

2.17.1 (2024-09-03)

Bug Fixes

2.17.0 (2024-08-23)

Features

  • update getFunctionalInterface to return the method being passed instead of just executing (#552) (ebb41f8), closes #524

2.16.3 (2024-08-14)

Bug Fixes

  • test for localStorage before using it and enable it to be shimmed with a Storage-compatible interface (#550) (c3982f5), closes #541

2.16.2 (2024-08-09)

Bug Fixes

2.16.1 (2024-08-09)

Bug Fixes

2.16.0 (2024-08-06)

Features

  • add esm configuration to rollup/package.json and add the node/browser output files (#531) (bd14e19)

2.15.0 (2024-07-09)

Features

  • add query id inference for conversion events based on prior clicks (#534) (ca2f234)
  • query id inference pruning of purchased and oldest associations when limit is reached (#535) (2e0ca49)

2.14.0 (2024-05-22)

Features

2.13.0 (2023-12-11)

Features

  • add value property to non-search-related conversion events (#528) (e624693)

2.12.0 (2023-12-11)

Features

  • add value property to conversion events (#526) (ab761ae)

2.11.0 (2023-11-17)

Features

  • enable unsetting authenticatedUserToken (#518) (aa1198a)

2.10.0 (2023-11-07)

Features

  • introduce native fetch fallback when http-module is not supported (#515) (6a322a4), closes #444

2.9.0 (2023-10-13)

Features

  • add support for authenticatedUserToken (#513) (0636a2d)

2.8.3 (2023-09-25)

Bug Fixes

  • expose purchase and addToCart insights client methods (#511) (6c3a322)

2.8.2 (2023-09-05)

Bug Fixes

  • add missing type defs for conversion subtypes (#508) (b804bb5)

2.8.1 (2023-09-01)

Bug Fixes

  • remove engines config from package.json (#496) (0bef4a5)

2.8.0 (2023-08-30)

Features

2.7.0 (2023-07-11)

Features

  • request: enable requests to be awaited upon (#483) (e69f7c9)

2.6.0 (2023-04-20)

Bug Fixes

  • readme: update code snippet to reflect version (#445) (edd2b3a)

Features

  • userToken: generate in-memory anonymous user tokens by default (#441) (161c933)

2.5.0 (2023-04-19)

Features

2.4.0 (2023-03-16)

Features

  • make init optional (#415) (c774652)
  • expose version string from functional interface (#413) (8a3f8f9)
  • allow to init again while preserving passed options (#401) (0e66c34)
  • pass custom credentials as additional arguments of insights methods (#399) (3f66ff4)

2.3.0 (2023-02-16)

Features

  • api: expose window.AlgoliaAnalyticsObject if not yet set (#390) (493eefd)

2.2.3 (2022-11-16)

Bug Fixes

  • add default Content-Type and Content-Length headers to XMLHttpRequest instance (1249920)
  • check headers setup in tests (39a29a6)

2.2.2 (2022-11-16)

Bug Fixes

  • add default Content-Type and Content-Length headers to XMLHttpRequest instance (1249920)
  • check headers setup in tests (39a29a6)

2.2.1 (2021-12-14)

Bug Fixes

2.2.0 (2021-12-07)

Bug Fixes

  • fall back to XHR if sendBeacon returns false (#336) (809fe47)

Features

2.1.0 (2021-10-26)

Features

  • export AlgoliaAnalytics, getFunctionalInterface and processQueue (#333) (a95520b)

2.0.5 (2021-10-18)

Bug Fixes

  • types: make callback optional at onUserTokenChange (#331) (36c980e)

2.0.4 (2021-10-13)

Bug Fixes

  • remove initSearch method (no longer in use) (#327) (b4b4e9e)
  • remove validation before sending events (#325) (2b7f1a6)

2.0.3 (2021-09-07)

Bug Fixes

  • bundle: remove unnecessary exports from bundles (#320) (92ee346)

2.0.2 (2021-07-27)

Bug Fixes

  • provide iife build to prevent conflicts with AMD (#274) (5e8f3ba)
  • types: make eventName required (#275) (04ad058)

2.0.1 (2021-07-05)

Bug Fixes

  • types: provide better error messages for insights client (#269) (8b678e8)

2.0.0 (2021-04-28)

BREAKING CHANGES

  • useCookie: It used to be true, but to be GDPR compliant, we're changing it to false by default.

Bug Fixes

  • cookie: make useCookie false by default (#249) (8106034)
  • _get: remove the internal method _get (#256) (374f9fb)

1.8.0 (2021-04-28)

Bug Fixes

  • types: expose the types of public methods (#259) (d59afaa)

Features

1.7.2 (2021-04-26)

Bug Fixes

  • types: export default (#257) (55dd748)
  • types: export default in the type definition (#247) (10044fc)
  • userToken: prevent anonymous user token from overriding existing token (#251) (738e5d9)

1.7.1 (2021-01-25)

Bug Fixes

  • types: emit and publish type definitions to npm (#243) (074f037)

1.7.0 (2021-01-13)

Bug Fixes

  • use browser requester on browser with bundler (#238) (df62ffd)
  • warn about unknown function name (#237) (dd46015)

Features

  • init(userToken): accept new parameter userToken at init() method (#241) (29216c6)
  • init(useCookie): accept new parameter useCookie which skips anonymous userToken when false is given (#236) (db09c7e)

1.6.3 (2020-11-02)

Bug Fixes

  • do not store anonymous token in cookie when user has opted out (#233) (8669b67)

1.6.2 (2020-09-02)

Bug Fixes

1.6.1 (2020-08-28)

Bug Fixes

  • package: include empty module (c4cf25d)

1.6.0 (2020-08-13)

Features

  • react-native: shim native node modules (#220) (713cbf9)

1.5.0 (2020-07-23)

Features

  • browser: expose createInsightsClient (#213) (7880205)
  • get: add _get function to get instance variables (#216) (3173c9b)
  • add onUserTokenChange to know when token is assigned (#209) (1e5bd42)
  • export createInsightsClient for node env (#203) (4f04869), closes #204 #204

1.4.0 (2020-02-17)

Bug Fixes

  • gtm: add Algolia Agent after init (9640dc2)
  • gtm: forward eventName to all events (1209301)
  • types: remove optional types on main methods (#192) (e551d10)

Features

  • sendEvent: return the value of the request function (#200) (56b4ffd), closes #199

1.3.0 (2019-09-18)

Bug Fixes

1.2.0 (2019-04-24)

Features

  • getUserToken: add a way to get user token (#107) (29786e1)

1.1.1 (2019-04-11)

Bug Fixes

  • UserAgent: change shape of user agent to reflect other flavours (#109) (cc1babf)

1.1.0 (2019-04-11)

Features

  • UserAgent: add user agent string (#100) (09141a1)
  • UserAgent: introduce addAlgoliaAgent method (#105) (927e74e)
  • version: expose version in main class (#99) (12bd554)

1.0.1 (2019-01-17)

Features

  • doc: add migration section (282aa0e)

1.0.0 (2018-12-17)

Bug Fixes

Features

  • cookieDuration: add cookieDuration support (#61) (66a4a69)
  • userToken: accepting provided userToken (#64) (f7d63ee)