
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
alg-insights
Advanced tools
Library for detecting front-end search metrics
Algolia insights library allows developers to report click and conversion metrics related
to search queries. It does so by correlating events with queryIDs generated by the search API when a query parameter clickAnalytics=true is set.
Once a search has been initialized and the queryID received, the library currently supports two types of events - click and conversion.
Insights library can be either loaded via jsDelivr CDN or directly bundled with your application. We recommend loading the library by adding the snippet below to all pages where you wish to track search search analytics.
<script>
!function(e,a,t,n,s,i,c){e.AlgoliaAnalyticsObject=s,e.aa=e.aa||function(){(e.aa.queue=e.aa.queue||[]).push(arguments)},i=a.createElement(t),c=a.getElementsByTagName(t)[0],i.async=1,i.src="https://cdn.jsdelivr.net/npm/alg-insights@0.1.0/dist/alg-insights.js",c.parentNode.insertBefore(i,c)}(window,document,"script",0,"aa");
// Initialize library
aa('init', {
apiKey: 'SEARCH_API_KEY',
applicationID: 'APPLICATION_ID'
})
</script>
In order for the Algolia engine to return a queryID on each search request, a special query parameter clickAnalytics=true should be set.
InstantSearch
const search = instantsearch({
appId: 'APPLICATION_ID',
apiKey: 'SEARCH_API_KEY',
indexName: 'INDEX_NAME',
searchParameters: {
clickAnalytics: true
}
});
algoliasearch-helper:
const helper = algoliasearchHelper(client, 'INDEX_NAME', {
clickAnalytics: true
});
After loading the library you will need to call the initSearch function of the library and provide a callback function that will return the queryID sent by the Algolia engine. The queryID can be retrieved from the raw results array inside your helper.
// Initialize search analytics -
// should be called after the UI has rendered
// and you have the reference to search state and
// inputSelector exists in the DOM
aa('initSearch', {
getQueryID: () => search.helper.lastResults && search.helper.lastResults._rawResults[0].queryID
})
To report a click event, you have to call aa('click',{objectID: clickedObjectID, position: positionOfElement}).
Depending on the library and implementation details, these two can both be done straight from the hit template or in a custom event handler.
Upon a conversion event, the API is a bit different and you will only have to call the conversion event with aa('conversion',{objectID: clickedObjectID}). The 2nd parameter is the same as above, it is the ID of the clicked result. This ID will be used to derive the queryID. Internally, the library keeps a store of associated click and search events. When a conversion event happens, it tries to correlate the conversion to a click event via the queryID. If no event is found, it assumes that the conversion event did not happen as a result of search.
All library examples are done with an assumption, that you have already completed the first step of loading the library.
To run all examples and play around with the code you have to run two separate commands:
yarn dev - runs webpack and node dev serveryarn build:dev - runs rollup in watch mode - livereload if you do changes to the insights libraryFAQs
Search engine analytics
The npm package alg-insights receives a total of 34 weekly downloads. As such, alg-insights popularity was classified as not popular.
We found that alg-insights demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.