Guest User

Untitled

a guest
Dec 15th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <script>
  2. // get the current url
  3. var curUrl = window.location.href
  4. // Extract the utm codes
  5. var myRegExp = /(utm_\w+=\w+[^&])/g;
  6. var utms = curUrl.match(myRegExp)
  7. //Extract the destination url
  8. var destinationRegex = /destination=(.+?)(&utm|$)/;
  9. var rawdDestination = curUrl.match(destinationRegex)[1]
  10. var decodedDestination = decodeURIComponent(rawdDestination)
  11. // build a new url with the utm codes
  12. var utmJoined = utms ? utms.join("&"): ""
  13. var newUrl = decodedDestination+"/"+utmJoined
  14. // Redirect to the new url
  15. window.location = encodeURI(newUrl);
  16. </script>
Add Comment
Please, Sign In to add comment