Spotler Activate Search is easily implemented. This article explains how to install it onto your environment.
Step 1: placing the snippet on your website
Simply copy the Javascript snippet shown on this page and paste it into the head or footer section of your pages.
- Log in to Google Tag Manager and select the right container
- In the menu, go to Tags
- Click on the button with New
- Click on Tag Configuration
- Add a custom HTML tag
- Paste the Search snippet you can copy from this page
- Trigger this tag on every page containing the search bar
- Click on the button with Save on the top and name your tag Spotler Activate Search
- Now click Submit and after that, click on Publish.
Spotler Activate Seach should now be linked to your website!
Step 2: change the ID of the search bar to Search
This needs to be a unique value, so we know which input field to use. If it’s impossible to adjust the ID of your search bar, you can try to change the field ID Search in the snippet, to the ID of your input field. In any case, the ID of your input field and the ‘fieldId’ as noted in the snippet should always be the exact same value.
_wssq.push(['_load',{'suggest':{'account':'SQ-'+ sooqrAccount,'version':4, fieldId :'change this value'}}]);
https://spotler.atlassian.net/wiki/spaces/ASPRODKB/pages/803340613/Integration+-+Search+Snippet
Extra code
To hide the keyboard on mobile devices you can add the code below before the Search snippet. As it works with focus, this will also deselect the input on the desktop.
Don't forget the replace [search field id] with the ID of your search field.
jQuery('#<search field id>').bind('keypress', function(e) {var code = e.keyCode || e.which;if(code == 13) {jQuery('#<search field id>').blur();}});
if (req.http.host == "dynamic.sooqr.com" && req.url == "/") { return (pass); }
Whenever you have two search bars on your page (one mobile, one desktop OR one on top of the page and one on the bottom), here is how to fix this.
Make sure the ID of every search bar is unique.
<input id="search" type="search" name="q" value="" class="input-text required-entry" placeholder="Search the entire store"/>Example of the second search bar:
<input id="search2" type="search" name="q" value="" class="input-text required-entry" placeholder="Search the entire store"/>Add the search bar ID's in this line in the snippet, after fieldId:
_wssq.push(['_load', { 'suggest' : { 'account' : 'SQ-123456-1', version: '4', fieldId: ['search', 'search2']}}]);
connect-src https://*.sooqr.com https://firehose.eu-central-1.amazonaws.com https://cognito-identity.eu-central-1.amazonaws.com;
_wssq.push(['suggest._bindEvent', 'open', function() {
$jQ(document).mouseup(function (e){
var container = $jQ(".sooqrSearchContainer");
if (!container.is(e.target) && container.has(e.target).length === 0){
websight.sooqr.instances['SQ-000000-0'].hideContainer();
}
});
}]);