Advertisement
NikolayBezay

Bezeq save last product in browser GTM teg.

Jul 26th, 2021
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.88 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     function saveProductInformation() {
  4.         var excludeList = [ "apple", "smartphone", "consolegames", "scruples" ];
  5.         var productFullTitle = document.querySelector('h1.product-title');
  6.         var productName = document.querySelector('h1.product-title .product-name');
  7.         var isProductValid = true;
  8.         excludeList.forEach(item => {
  9.             if (window.location.href.indexOf(item) != -1) {
  10.                 isProductValid = false;
  11.             }        
  12.         });
  13.         if (productFullTitle && productName && isProductValid) {
  14.            window.localStorage.setItem('adoricLastVisitedProductName', productName.textContent);
  15.             window.localStorage.setItem('adoricLastVisitedProductLink', window.location.href);
  16.         }
  17.     }
  18.     saveProductInformation();
  19.     setTimeout(saveProductInformation, 3000);
  20. })();
  21. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement