We're trying to implement Site Search with a custom search field. However, if a user types something in the field and then hits "return", this error appears in the console:
st.js:73 Uncaught TypeError: window.ga is not a function
at Object.n.Utils.pushToGA (st.js:73)
at Swiftype.QueryContext.pQueryContext.pushQueryToGA (st.js:74)
at Swiftype.QueryComposer.pQueryComposer.runSearch (st.js:74)
at HTMLInputElement.<anonymous> (st.js:74)
at HTMLInputElement.dispatch (st.js:25)
at HTMLInputElement.y.handle (st.js:24)
At a quick glance, it does appear to be a conflict with another asset on the page. Would it be possible to include a link to where this error can be observed along with any steps to reproduce it?
If you'd rather not include that information within a community post, please reach out to the Support team with the above information and context: https://www.elastic.co/support/welcome/swiftype
It does appear to be a script related to your GA via GTM that may be butting heads with our embed snippet's built in behavior to pass the site search query value to your GA endpoint.
In the past I've seen asset load order being the culprit, so I did a quick test with a barebones HTML boilerplate and added your Swiftype embed script before the GTM script within the <head></head> container and then included the input element within the <body>.
Under these circumstances the search overlay performed as expected without triggering the error.
I'm afraid we're unable to support or debug non-Swiftype related scripts/conflicts, but if you're able to pinpoint a valid bug we can escalate to our engineering team.
Hmm, that's pretty weird. I pulled out our GA script, and every other script loading on the page, and the error still appears.
Is the swiftype script restricted to the domain? So that if my staging/local environment domains don't exactly match my site's domain, then it would throw that error? Is there somewhere I need to whitelist staging/dev domains?
That is odd. There's no domain specific restriction for the script to function. For the tests where you've removed every script other than Swiftype, have you tried clearing the cookies/cache if loading from the same staging domain and/or doing the barebones template test?
I'm curious if there's some other (potentially) minified asset loading that's calling additional scripts.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.