Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. $(function() {
  2. var reachedBottomTracked;
  3. var scrolledTracked;
  4. $('nav.global a').click(function(event) {
  5. if (
  6. location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
  7. location.hostname == this.hostname
  8. ) {
  9. var target = $(this.hash);
  10. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  11. if (target.length) {
  12. event.preventDefault();
  13. $('html, body').animate(
  14. {
  15. scrollTop: target.offset().top
  16. },
  17. 1000
  18. );
  19. gtag('event', 'navV8_' + this.hash.slice(1));
  20. }
  21. }
  22. });
  23. $(window).on('scroll', function() {
  24. if (!scrolledTracked) {
  25. scrolledTracked = true;
  26. gtag('event', 'scrolledV8');
  27. }
  28.  
  29. if (
  30. !reachedBottomTracked &&
  31. $(window).scrollTop() + $(window).height() === $(document).height()
  32. ) {
  33. reachedBottomTracked = true;
  34. gtag('event', 'reached_bottomV8');
  35. }
  36. });
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement