Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // Parse the URL to get the required field values
- function getUtmParamByName(utmname) {
- utmname = utmname.replace(/[[]/, "\[").replace(/[]]/, "\]");
- var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
- results = regex.exec(location.search);
- return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
- }
- // Give the URL parameters variable names
- var source = getUtmParamByName('utm_source');
- var medium = getUtmParamByName('utm_medium');
- var campaign = getUtmParamByName('utm_campaign');
- var content = getUtmParamByName('utm_content');
- var term = getUtmParamByName('utm_term');
- // Put the variable names into the hidden fields in the form.
- $( document ).ready(function() {
- $('#form-field-utm_source').val(source);
- $('#form-field-utm_medium').val(medium);
- $('#form-field-utm_campaign').val(campaign);
- $('#form-field-utm_content').val(content);
- $('#form-field-utm_term').val(term);
- }
- </script>
Add Comment
Please, Sign In to add comment