Guest User

Untitled

a guest
Oct 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <script type='text/javascript'>
  2.  
  3. //Enter conditions here to determine whether or not visitor is a registered user.
  4. window.isRegisteredUser = false;
  5.  
  6. //Global variable to determine amount of time spent on site.
  7. var SECONDS_SPENT_ON_SITE = 120;
  8.  
  9. olark('api.rules.defineRule', {
  10.  
  11. // Specify a unique ID for this rule. This helps the API to keep your
  12. // rules separate from each other.
  13. id: '1',
  14.  
  15. // The description is a good way to summarize what this rule is doing
  16. description: "offer help to a visitor after he has spent x amount of time on site and if he is not a registered user",
  17.  
  18. // The condition will be checked whenever there is a relevant change
  19. // in the chat, just call pass() whenever it meets the criteria
  20. condition: function(pass) {
  21.  
  22. // you can use the Visitor API to get information like page count, seconds spent on site, etc.
  23. olark('api.visitor.getDetails', function(details){
  24.  
  25. if (details.secondsSpentForThisVisit >= SECONDS_SPENT_ON_SITE && !details.isConversing && !window.isRegisteredUser) {
  26. // we have met the condition of time spent is over SECONDS_SPENT_ON_SITE,
  27. // and the visitor has not started chatting yet,
  28. // and the visitor is not a registered user
  29. // so mark this condition as passed
  30. pass();
  31. }
  32.  
  33. });
  34.  
  35. },
  36.  
  37. // The action will be executed whenever the condition passes. You can
  38. // automatically limit the number of times this action will trigger by
  39. // using the perPage, perVisit, and perVisitor options.
  40. action: function() {
  41. olark('api.chat.sendMessageToVisitor', {
  42. body: "Hi, have any questions about our products?"
  43. });
  44. },
  45.  
  46. // Restrict the action to execute only once per visit, that way offering
  47. // help doesn't happen over and over for the same visitor
  48. perVisit: true
  49.  
  50. });
  51. </script>
Add Comment
Please, Sign In to add comment