Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // get the current url
- var curUrl = window.location.href
- // Extract the utm codes
- var myRegExp = /(utm_\w+=\w+[^&])/g;
- var utms = curUrl.match(myRegExp)
- //Extract the destination url
- var destinationRegex = /destination=(.+?)(&utm|$)/;
- var rawdDestination = curUrl.match(destinationRegex)[1]
- var decodedDestination = decodeURIComponent(rawdDestination)
- // build a new url with the utm codes
- var utmJoined = utms ? utms.join("&"): ""
- var newUrl = decodedDestination+"/"+utmJoined
- // Redirect to the new url
- window.location = encodeURI(newUrl);
- </script>
Add Comment
Please, Sign In to add comment