ecedi/utmze by Agence Ecedi
This is an alternative solution for tracking campaign as __utmz cookie is no more available with Google Analytics Universal
{
"require": {
"ecedi/utmze": "dev-master",
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ecedi/utmze"
}
]
}
this script will emulate __utmz cookie behavior to track traffic source, campaign and medium (other data are not supported so far)
campaign aka utmccn is false by default, when a GET parameter utm_campaign is set, it will be stored and stick until another utm_campaign is found
medium aka utmcmd is false by default, when a GET parameter utm_medium is set, it will be stored and stick until another utm_campaign is found
Source aka utmcsr is a little bit more tricky: it is (direct) by default,when a GET parameter utm_source is set, it will be stored and stick until another utm_source is found
in header
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="/jquery-utmz.min.js"></script>
</head>
before </body>
<script type="text/javascript">
$(document).ready(function() {
$().utmz();
}
</script>
If you want to parse the cookie in PHP, use any standard code you already use.
Here are some classic code to look at
- Google Analytics PHP cookie parse
- Code Example: Google Utmz Cookie Parser
- Campaign Tracking - Web Tracking (ga.js)
The cookie match the __utmz spec
in auto mode jquery-utmz will try to write on all sub domains
If website domain is client.inte.paris.ecedi.fr jquery-utmz will try to write (in this order) * .ecedi.fr * .paris.ecedi.fr * .inte.paris.ecedi.fr * .client.inte.paris.ecedi.fr
specify the cookie path
define the max age of the utmz cookie, 2 month by default (61 days)
<script type="text/javascript">
$(document).ready(function() {
$().utmz({ expires: 7});
}
</script>
define the cookie name, __utmze by default to not overlap with any old Google Analytics __utmz cookie
If you know what you are doing you can override to use the __utmz name
<script type="text/javascript">
$(document).ready(function() {
$().utmz({ cookieName: '__utmz'});
}
</script>