NikolayBezay

Toyota save UTM for Adoric GTM teg

Nov 28th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.92 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     function getUrlParameter(name) {
  4.         name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  5.         var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
  6.         var results = regex.exec(location.search);
  7.         return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, " "));
  8.     }
  9.  
  10.     var adoricUtm = {
  11.         utm_source: getUrlParameter('utm_source'),
  12.         utm_medium: getUrlParameter('utm_medium'),
  13.         utm_campaign: getUrlParameter('utm_campaign'),
  14.         utm_term: getUrlParameter('utm_term'),
  15.         utm_content: getUrlParameter('utm_contente'),
  16.         isEmpty: true
  17.     }
  18.     for(key in adoricUtm) {
  19.         if (key !== 'isEmpty' && adoricUtm[key].length > 0) {
  20.            adoricUtm.isEmpty = false;
  21.         }
  22.     }
  23.     if (!adoricUtm.isEmpty) {
  24.         window.localStorage.setItem('adoricUtm', JSON.stringify(adoricUtm));
  25.     }
  26. })();
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment