Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const queryString = window.location.search;
- const urlParams = new URLSearchParams(queryString);
- const utm = urlParams.get('utm_source');
- if (utm) {
- var myVar = utm;
- }
- function getCookie(cname) {
- let name = cname + "=";
- let decodedCookie = decodeURIComponent(document.cookie);
- let ca = decodedCookie.split(';');
- for(let i = 0; i <ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) == ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- }
- zztop = getCookie('_shopify_sa_p');
- const zz = new URLSearchParams(zztop);
- var cook_utm = zz.get('utm_source');
- if (cook_utm) {
- var myVar = cook_utm;
- }
- console.error('utm myVar = '+myVar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement