NikolayBezay

Toyota save UTM for Adoric GTM teg NEW

Feb 6th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.11 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.         camp_id: getUrlParameter('campid'),
  17.         adgroup_id: getUrlParameter('adgroupid'),
  18.         ad_id: getUrlParameter('ad_id'),
  19.         isEmpty: true
  20.     }
  21.     for(key in adoricUtm) {
  22.         if (key !== 'isEmpty' && adoricUtm[key].length > 0) {
  23.            adoricUtm.isEmpty = false;
  24.         }
  25.     }
  26.     if (!adoricUtm.isEmpty) {
  27.         adoricUtm.URL = window.location.href;
  28.         window.localStorage.setItem('adoricUtm', JSON.stringify(adoricUtm));
  29.     }
  30. })();
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment