Skip to content
Official Smartlook client for easy frontend integration.
TypeScript
Branch: master
Clone or download
Latest commit 997c5a6 Nov 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist chore: update type of identify method Nov 25, 2019
.gitignore
.prettierignore
LICENSE npm init May 31, 2017
README.md chore: update type of identify method Nov 25, 2019
index.ts chore: update type of identify method Nov 25, 2019
package.json 4.2.0 Nov 25, 2019
tsconfig.json Rewrite to Typescript, add types, use ES5 build Nov 21, 2018
yarn.lock

README.md

Smartlook-client

Imports and initializes Smartlook recorder into a page.

  1. Installation

    npm install smartlook-client --save
    

    or

    yarn add smartlook-client
    
  2. Import

    import smartlookClient from 'smartlook-client'
    

    or

    var smartlookClient = require('smartlook-client')
    
  3. API

    init(string key)
    
    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()
    
    error(string | Error error)
    
  4. 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',
         // other custom properties
       })
      }
      handleTrack = () => {
       smartlookClient.track('transaction', {
         "value": 150,
         "currency": "usd",
         "product": "Product Description",
         // other custom properties
       });
      }
     handleDisable = () => {
       smartlookClient.disable()
     }
      render() {
        return (
          <div>
            <button onClick={this.handleIdentify}>Identify visitor</button>
           <button onClick={this.handleTrack}>Track event</button>
            <button onClick={this.handleDisable}>Disable recording</button>
          </div>
        )
      }
      componentDidMount() {
        smartlookClient.init('43bc84d9a8406exxxxxxxxxb5601f5bbf8d2ed')
      }
    }
    
    export default App
    

For more info visit https://www.smartlook.com/docs/api.html

You can’t perform that action at this time.