filipr27

cHTML - SPA pageview URL no historyChange

Jul 4th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.   var currentPage = window.location.href;
  3.   var pagePath = window.location.pathname;
  4.  
  5. // listen for changes
  6. setInterval(function()
  7. {
  8.     if (currentPage != window.location.href)
  9.     {
  10.           window.dataLayer = window.dataLayer || [];
  11.           window.dataLayer.push({
  12.             'event': 'newPage'
  13.            });
  14.        
  15.         currentPage = window.location.href;
  16.     }
  17. }, 500);
  18. </script>
Advertisement
Add Comment
Please, Sign In to add comment