API
init(string key)
init(string key, params?: { region?: 'eu' | 'us', version?: 'legacy' | 'nextgen' })
track(string eventName, object<key:value> props)
identify(integer | string userId, object<key:value> props)
anonymize()
disable()
consentForms(string | false consent)
consentIP(string | false consent)
consentAPI(string | false consent)
getData(function callback)
restart()
pause()
resume()
error(string | Error error)
navigation(string locationOrPath)
properties(object<key:value> properties)
initialized()
playUrl
sessionId
visitorId
recordId
key
version
Example usage in React
Usage in other libraries is similar.
import React, { Component } from 'react'
import smartlookClient from 'smartlook-client'
class App extends Component {
handleIdentify = () => {
smartlookClient.identify(12345, {
name: 'John Doe',
email: 'email@domain.com',
})
}
handleTrack = () => {
smartlookClient.track('transaction', {
value: 150,
currency: 'usd',
product: 'Product Description',
})
}
handlePause = () => {
smartlookClient.pause()
}
render() {
return (
<div>
<button onClick={this.handleIdentify}>Identify visitor</button>
<button onClick={this.handleTrack}>Track event</button>
<button onClick={this.handlePause}>Pause recording</button>
</div>
)
}
componentDidMount() {
smartlookClient.init('43bc84d9a8406exxxxxxxxxb5601f5bbf8d2ed')
}
}
export default App