UTM Capturing and Storing in Cookies


This Javascript code automatically captures UTM parameters of your website visitors.
It captures both first and last interactions and storing the data in the browser cookies for 365 days (see: cookieExpiryDays variable in the code).

Learn more about our Multi-Touch Attribution solution


  1. There are 2 versions of the script, one is minified (without the comments and spaces) and the original. It’s recommended to use the minified version.
  2. If you install the script using Google Tag Manager, you should create a new Custom HTML container, first add <script>THE_CODE_GOES_HERE</script>, then paste the code between the 2 script tags.

Need help or have any questions? We’d be happy to assist 🙂

First Touch Cookies:

Last Touch Cookies:


Related post: Marketing Attribution Tracking in Marketo – Aren’t You Forgetting Something?


Source Code



One Reply to “UTM Capturing and Storing in Cookies”