You can find a general guide for how to implement Analytics Tags here, and you can learn more details about our analyticsTags parameter here.
Here is an example in which we set Analytics Tags for different devices after writing your function to detect the device:
const getPlatform = () => { const isMobile = ... // your logic to determine whether a user is on mobile or desktop return isMobile ? 'mobile' : 'desktop'; };
You would then use it with the configure widget to set the tag:
const platformTag = getPlatform(); instantsearch.widgets.configure({ analyticsTags: [platformTag], });
To do this with a Magento implementation, you will need to customize your front end through the use of a front end hook. The hook would look something like this:
algolia.registerHook('beforeWidgetInitialization', function(allWidgetConfiguration, algoliaBundle) { const getPlatform = () => { const isMobile = ... // your logic to determine whether a user is on mobile or desktop return isMobile ? 'mobile' : 'desktop'; }; const widgetConfig = { analyticsTags: [platformTag], }; if (typeof allWidgetConfiguration['configure'] === 'undefined') { allWidgetConfiguration['configure'] = [widgetConfig]; } else { allWidgetConfiguration['configure'].push(widgetConfig); } return allWidgetConfiguration; });
Here is our guide for modifying the front end in Magento 2, which you may also find useful.
Please note that front end customizations are out-of-scope for the Support team.