Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <script>
  2. // Parse the URL to get the required field values
  3.  
  4. function getUtmParamByName(utmname) {
  5.  
  6. utmname = utmname.replace(/[[]/, "\[").replace(/[]]/, "\]");
  7.  
  8. var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
  9.  
  10. results = regex.exec(location.search);
  11.  
  12. return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
  13.  
  14. }
  15. // Give the URL parameters variable names
  16. var source = getUtmParamByName('utm_source');
  17. var medium = getUtmParamByName('utm_medium');
  18. var campaign = getUtmParamByName('utm_campaign');
  19. var content = getUtmParamByName('utm_content');
  20. var term = getUtmParamByName('utm_term');
  21. // Put the variable names into the hidden fields in the form.
  22. $( document ).ready(function() {
  23. $('#form-field-utm_source').val(source);
  24. $('#form-field-utm_medium').val(medium);
  25. $('#form-field-utm_campaign').val(campaign);
  26. $('#form-field-utm_content').val(content);
  27. $('#form-field-utm_term').val(term);
  28. }
  29. </script>
Add Comment
Please, Sign In to add comment