Javascript plugin for Google Analytics analytics.js to recreate the functionality of the __utmz cookie (which no longer exists with Universal Analytics). Some Google Analytics users came to rely on the cookie format of __utmz, and would parse it for other data collection work. When that cookie went missing, stuff broke. This will hopefully fix those cases.
There are two ways to use this: As a Universal Analytics Tracking Plugin or as a standalone script.
- Download the latest version of the GA plugin from compiled/latest/utmz_ga.min.js
- Host it on your web server.
- Add a
<script async src="/PATH_TO_JS/utmz_ga.min.js"></script>
on each page - Wherever your Google Analytics tag is, add
ga('require', 'utmz', { cookies: document.cookie });
directly after thega('create', ...)
command. - Add
ga('utmz:runDefaultBehaviour');
right after thega('send', ...)
command.
- Add a
<script async src="https://cdn.rawgit.com/clancychilds/ReturnOfTheUTMZ/master/compiled/latest/utmz_ga.min.js"></script>
on each page - Wherever your Google Analytics tag is, add
ga('require', 'utmz', { cookies: document.cookie });
directly after thega('create', ...)
command. - Add
ga('utmz:runDefaultBehaviour');
right after thega('send', ...)
command.
- Download the latest version of the standalone script from compiled/latest/utmz.min.js
- Host it on your web server.
- Add
<script async src="/PATH_TO_JS/utmz.min.js"></script>
on each page (or via a tag manager)
- Add
<script async src="https://cdn.rawgit.com/clancychilds/ReturnOfTheUTMZ/master/compiled/latest/utmz.min.js"></script>
on each page (or via a tag manager)
That should be it. However, this is still in development.
There are many. They will be tracked under Issues on github. PLEASE feel free to contribute!
Please fork and submit pull requests. Ideally log and take an Issue in github.
Please make sure that gulp lint
and gulp test
don't send errors and please add unit tests where possible.
Initial alpha. Supports utm_ tags and general referer parsing and cookie checking, but has a ton of TODOs. It will probably work for the most general cases (e.g. no tricky cookie settings) and doesn't capture timestamps. I'm not super happy with all of the hacked-together decisions to get this released, but at least it is a starting point to improve from.
Added the ability to run this as a non-GA tracking plugin. I had to do this because I realized that there are cases where people want the cookie but don't want GA and also that when using Google Tag Manager, it is not possible to specify Universal Analytics plugin requirements.
Make it so that the cookies are, by default, set at the '/' path and on the primary domain.
Added support for utm_content
and utm_id
. Thanks to thyngster