Advertisement
NikolayBezay

LivnatPoran new UTM functionality GTM teg.

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