UTM Trackers & Cookies
The intention of UTM tracker plugins is:
- To collect UTM, referrer and similar information from the first user visit and store this information as a cookie
- To embed this info into every form on-site, by default, so we can use it and submit it together with the 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!
-
UTM Tracker plugin with repo lludwig/utm-tracker: Wordpress 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. -
HandL UTM Grabber plugin
Useful Guides: UTM Definitive Guide, Contact Form 7 Integration, Documentation
Easy UTM Tracking with Contact Form 7 UTM Switcher UTM tags + Landing page + “gclid” tracking for Contact Form 7 Source Tracking for Contact Form 7
Configuring UTM Tracker
Domain must be prefixed with a period like “.cnc24.com” to allow cookies to propagate on subdomains also.
JS libraries ‘utm_cookie’ and ‘utm_form’
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() || '' )
Manual way to capture cookies from UTM parameters in the URL.
UTM Parameters w/ Vanilla JavaScript | by Jay Papisan | Medium
Možda mi može pomoći oko manipulacije UTM_ parametrima: URL Params
Ja sam sam implementirao tako što sam ručno dodao u formu: