Instantsearch.js: Click Analytics window.aa error

Created on 8 Mar 2018  路  5Comments  路  Source: algolia/instantsearch.js

Hi. I'm trying to implement Search and Click Analytics with this tutorial:
https://www.algolia.com/doc/tutorials/getting-started/how-to-implement-analytics/#reporting-click-and-conversion-events

I added this to instantsearch:

searchParameters: {
    clickAnalytics: true // adding clickAnalytics true enables queryID
  }

and this:

search.once('render',() => {
    window.aa('initSearch', {
      getQueryID: () => {
        return search.helper.lastResults && search.helper.lastResults._rawResults[0].queryID
      }
    })
  })

I understand i have to create buttons with data-something and global eventlistener to catch data. But i have an error like this:

Uncaught TypeError: window.aa is not a function
    at t.search.once (algolia_search.js:33)
    at t.n (events.js:165)
    at t.n.emit (events.js:78)
    at t.value (InstantSearch.js:335)
    at r.n.emit (events.js:84)
    at algoliasearch.helper.js:1245
    at n (_arrayEach.js:15)
    at r (forEach.js:37)
    at r._dispatchAlgoliaResponse (algoliasearch.helper.js:1238)
    at AlgoliaSearchCore.js:446

Most helpful comment

Done and it works :) Than you very much. I forgot about library :)

All 5 comments

Hey @SchmidtDawid, you seem to be using both autocomplete.js and instantsearch.js through each other, can you give the complete code in a fiddle please?

Don't forget to also load the library. See the README here for that 馃憤

Done and it works :) Than you very much. I forgot about library :)

Perfect, enjoy the analytics!

Was this page helpful?
0 / 5 - 0 ratings