Advertisement
Danielfc

script 1 - editor antigo - matheus - variação 2

Oct 3rd, 2023
1,190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  
  3. document.addEventListener('DOMContentLoaded', (event) => {
  4.  
  5.     let url = new URL(window.location.href);
  6.      
  7.     let params = new URLSearchParams(url.search);
  8.  
  9.     let utm_source = params.get('utm_source'); //vai ler o parametro da url
  10.     let utm_medium = params.get('utm_medium');
  11.     let utm_campaign = params.get('utm_campaign');
  12.     let utm_term = params.get('utm_term');
  13.     let utm_content = params.get('utm_content');
  14.     let utm_id = params.get('utm_id');
  15.      
  16.     document.querySelector('input[name="field[1]"]').value = utm_source;
  17.     document.querySelector('input[name="field[2]"]').value = utm_medium;
  18.     document.querySelector('input[name="field[3]"]').value = utm_campaign;
  19.     document.querySelector('input[name="field[4]"]').value = utm_id;
  20.     document.querySelector('input[name="field[5]"]').value = utm_term;
  21.     document.querySelector('input[name="field[6]"]').value = utm_content;
  22.      
  23. });
  24.  
  25.  
  26. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement