userTrack logo

Client side API

  1. Disable tracking yourself
    1. UST.disableRecord()
    2. UST.enableRecord()
  2. Dynamically tag clients
    1. UST.addTag('tag_name')
  3. Force send the recorded data
    1. UST.forceSendData()

1. Disable tracking yourself

Example

 // Starting with the next page load the tracking will be disabled
 UST.disableRecord();

 // Removes the "disabled" flag.
 // Starting with the next page load you will be tracked
 UST.enableRecord();

Instructions

  • To disable tracking yourself or other client you can call UST.disableRecord() from the JavaScript console or from a JS file.
  • To re-enable tracking the curent client call UST.enableRecord()
  • The tracking enabled/disabled flag is stored in the localStorage. As long as the browser localStorage is not cleared/reset this setting will persist. (eg: you won't be tracked again unless you clear all your browser data/cookies/localStorage)

2. Tag visitors dynamically

Example

// Call this when the scrollbar reaches the end
UST.addTag('scrolled_to_footer')

// Call this when user adds an item to the basket
UST.addTag('add_to_basket_timestamp: ' + Date.now())

Instructions

  • Sometimes you might want to save additional data for each tracked user (such as username or whether they clicked a button or not).
  • To add a tag the function UST.addTag() is provided. It has only one parameter which is the tag value. For example after calling this: UST.addTag("username_John") The tag will be saved for the current recording and you will be able to find it more easily.
  • You can also enable auto-tagging when certain elements are clicked. Add the HTML5 attribute data-UST_click_tag to set what tag will be added if the current element is clicked. Example: <input type="text" data-UST_click_tag="clicked_input" />. When this input is clicked the tag clicked_input will be added for this session. You will then be able to, for example, see only the recordings of users who clicked that specific input.

Notes

  1. Once written the value of tags can not be changed.
  2. Each tag is unique and can appear only once. If you call UST.addTag() again with the same tag name, nothing will happen.
  3. If you want more tags with similar name you can either add a random value or an unique id to each tag name.

3. Force send the recorded data

Example

// A request to send *new* data to the server will be created
UST.forceSendData();

Instructions

  • userTrack sends data to the server in an efficient way: it batches multiple actions made by the users and sends all of them at once in a single request. This means that sometimes you have recorded data stored on the client that hasn't been sent yet (it's queued to be sent in a specific amount of time). You can call UST.forceSendData() to reset the time left to send the next batch to 0, thus forcing userTrack to send the data as soon as possible.
  • One use case of this method is if you want to make sure the last seconds of the user's visit are recorded by calling UST.forceSendData() inside window onbeforeunload callback.
  • You could also call this function after the user makes an important action that you want to make sure has been sent to the server (eg: user clicks a specific button). Note that in this case you should also use UST.addTag()

results matching ""

    No results matching ""