UTM Trackers & Cookies

UTM Trackers & Cookies

Intention of UTM tracker plugins is:

  1. To collect UTM, referrer and similar information from first user visit and store this information as a cookie
  2. To embed this info into an every form on site, by default, so we can use it and submit it together with form

We are using only the first function, as the second is not needed for now.

Plugins we are using now

We had two plugins for the same task installed, and there is no need for both of them.
So let’s decide on the better one; and the decisive winner is - UTM Tracker!

  1. UTM Tracker plugin
    This article serves as a documentation, where he explicitly specifies that “this is a fork of script utm_form”.
    And that’s actually a good thing.

  2. HandL UTM Grabber plugin
    Useful Guides: UTM Definitive Guide, Contact Form 7 Integration, Documentation

Configuring UTM Tracker

Domain must be prefixed with a period like “.cnc24.com” to allow cookies to propagate on subdomains also.

Coding this feature is fairly straightforward, but is not needed as plugin UTM Tracker is obviously already using the code from the same library.

This JS library medius/utm_cookie saves UTM info in a cookie and another library medius/utm_form adds this extra UTM information as hidden fields on a any form. More explanation in accopanying article: How To Add UTM And Referrer Information To Lead Forms?

Again, very important!
When defining a cookie, the domain must start WITH a period, so cookies will propagate also to any subdomain, in our case: wizard.cnc24.com.

JavaScript Cookie Manipulation Snippets

As we are avoiding using jQuery anymore, the shortest vanilla-JS function to get a value of a cookie is the following:

const getCookie = (name) => ( document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() || '' )
date 05. Oct 2022 | modified 25. Oct 2022
filename: Plugins » UTM Trackers & Cookies