Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. window.optimizely = window.optimizely || [];
  2.  
  3. var clickedBanner = 0;
  4.  
  5. // Query Optimizely user events and filter to clicks
  6. var userBehaviorQueryData = optimizely.get("behavior").query({
  7. version: "0.2",
  8. sort: [{
  9. field: ["time"],
  10. direction: "descending"
  11. }],
  12. filter: [{
  13. field: ["type"],
  14. value: "click"
  15. }]
  16. });
  17.  
  18. // Loop through the events and increment by one each time the click event is found
  19. userBehaviorQueryData.forEach(function(event) {
  20. if (event.name === '1633341726_click_hero_banner') {
  21. clickedBanner += 1;
  22. }
  23. });
  24.  
  25. // Push the click value to a user attr which can be used in results segmentation
  26. window["optimizely"].push({
  27. "type": "user",
  28. "attributes": {
  29. "Clicked Hero Banner": clickedBanner
  30. }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement