Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://cdn.jsdelivr.net/npm/js-cookie@beta/dist/js.cookie.min.js"></script>
- <script type="module">
- // Parse the URL
- function getParameterByName(name) {
- name = name.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 = getParameterByName('utm_source');
- var medium = getParameterByName('utm_medium');
- var campaign = getParameterByName('utm_campaign');
- // Set the cookies
- if(Cookies.get('utm_source') == null || Cookies.get('utm_source') == "") {
- Cookies.set('utm_source', source);
- }
- if(Cookies.get('utm_medium') == null || Cookies.get('utm_medium') == "") {
- Cookies.set('utm_medium', medium);
- }
- if(Cookies.get('utm_campaign') == null || Cookies.get('utm_campaign') == "") {
- Cookies.set('utm_campaign', campaign);
- }
- // Grab the cookie value and set the form field values
- $(document).ready(function(){
- $('input[name=utm_source').val(utm_source);
- $('input[name=utm_medium').val(utm_medium);
- $('input[name=utm_campaign').val(utm_campaign);
- });
- Cookies.set('vapvarun', 'bar')
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement