
UTM Mangler - smacktoward
https://github.com/huntwelch/UTM-Mangler
======
vincentbarr
For those unfamiliar with UTM:

Urchin Tracking Module was an analytics package that Google acquired way back
when.

UTM defines a set of query parameters that Google Analytics, and other web
analytics platforms, use to capture and provide and information about a
referring source (or 'channel') to a webpage. At the highest-level, the
buckets are direct, organic, referrer, social, email, display, and paid
search.

The three UTM parameters that are required to track 'campaigns' in a web
analytics tool, such as Google Analytics:, are Utm_Source, Utm_Medium, and
Utm_Campaign.

Example: [http://stilldrinking.org/utms/utm-
mangler.html?utm_medium=so...](http://stilldrinking.org/utms/utm-
mangler.html?utm_medium=social&utm_source=facebook&utm_campaign=jan-15-hn-
woop-woop)

If you clicked on the link above, it would inform stilldrinking.org's Google
Analytics property that you, the visitor, came from Facebook and are part of
the 'jan-15-hn-woop-woop' campaign.

------
codezero
Unfortunately, this won't work for any analytics platform that uses first
interaction attribution, which most do. That means, they'll immediately store
the first value seen and treat that as the "source" for the visit. Changing it
will tweak per visit parameters, but won't really affect most people.

Still cool, but a better solution would be to make a plugin that mangles them
before the request is sent :)

~~~
yahelc
Can't speak for other analytics systems, but this is definitely not the case
for Google Analytics (which is what most utm_* parameters are targeting).

Google Analytics' default attribution (outside of Multichannel Funnels) is
_last_ touch attribution.

~~~
codezero
GA is definitely ubiquitous, but people serious about attribution aren't
limiting themselves to GA :P

------
kolev
Worst of all is when these are used in cache keys especially when some of
these get unique values. I did write a simple Nginx set of rules to strip this
off when used in the cache key or sending to the backend. Here's a fragment:
[https://gist.github.com/nikolay/e58fb0de98acd8aed932](https://gist.github.com/nikolay/e58fb0de98acd8aed932)

------
getdavidhiggins
Or just strip it entirely:

[https://github.com/wistia/fresh-url](https://github.com/wistia/fresh-url)

~~~
codezero
This one just removes it after people land on the page, it won't strip
attribution which is what it sounds like the OP is going for.

fresh-url is meant to aid site owners so that the users don't see the ugliness
of UTM codes :)

------
marssaxman
What is UTM?

~~~
shabble
I was expecting something Mapping/GIS related, given [1], but maybe that's
just the mental scar-tissue from a previous project involving various data
sources that were in formats not quite entirely unlike the ones they purported
to actually be. Which meant, along with one incredibly badly designed viewer
application, I could legitimately say "I spent almost an hour dragging myself
out of the ocean" in a worklog entry :P

[1]
[https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_...](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)

~~~
geogra4
Back in a previous life I used to work for a software company in the
defense/GIS space. It's pretty incredible how much labour goes in to making
the earth somehow representable as a series of X, Y and Z tuples. The
difference between floating and fixed point could mean being off by dozens of
metres.

