If you use the analytics with this configuration, pushFunction is not triggered when a user clicks on a new page. With the triggerOnUIInteraction option to true, we expect that it is.
movies.addWidget(
instantsearch.widgets.analytics({
pushFunction: function(formattedParameters, state, results) {
console.log('pushFunction')
},
pushInitialSearch: true,
triggerOnUIInteraction: true,
delay: 0,
})
);
Here is a jsfiddle reproducing the issue: https://jsfiddle.net/mthuret/j9nwpz34/23/
Hi @mthuret, thanks for opening this ;)
What do you mean by 'when a user clicks on a new page"? Is it like when a user clicks on a link?
When clicking on a link of the pagination widget, pushFuction is not triggered whereas if you select something using the refinement list it is.
This was first reported by a user on support.
There seems to be two problems here, in your example the clicks do not trigger the analytics function and when the page is updated is not called either.
Reproduced in v2: https://jsfiddle.net/bobylito/3yoa6285/
The bug with the pagination not sent with the analytics has been solved in 2.2.0-beta.1 (related PR). Also the triggerOnUIInteraction option is for triggering the analytics before we change page. Internally the widget is conservative and will not call the hook if the state hasn't changed.
Thanks for digging into this @bobylito! Will this fix be ported to v1 or update to v2 is the way to get it?
We have no plan to backport it (it's implemented as a feature) and it's not yet released as part of a stable release. Let me know if it causes too much problem and will find a way to backport it.
Most helpful comment
When clicking on a link of the pagination widget,
pushFuctionis not triggered whereas if you select something using the refinement list it is.This was first reported by a user on support.