ecedi / utmze

A source and campaign tracking alternative to Google Analytics UTMZ cookie

Home Page:https://www.ecedi.fr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ecedi/utmze by Agence Ecedi

This is an alternative solution for tracking campaign as __utmz cookie is no more available with Google Analytics Universal

installation

edit your composer.json file and add

	{
		"require": {
			"ecedi/utmze": "dev-master",
		},
		"repositories": [
			{
				"type": "vcs",
				"url": "https://github.com/ecedi/utmze"
			}
		]
	}

features

this script will emulate __utmz cookie behavior to track traffic source, campaign and medium (other data are not supported so far)

campaign behavior

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 behavior

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 behavior

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

Usage

javascript side

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>

PHP side

If you want to parse the cookie in PHP, use any standard code you already use.

Here are some classic code to look at

The cookie match the __utmz spec

options

domainName (default: auto)

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

cookiePath (default: /)

specify the cookie path

expires (default: 61)

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>

cookieName (default: __utmze)

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>

About

A source and campaign tracking alternative to Google Analytics UTMZ cookie

https://www.ecedi.fr

License:MIT License


Languages

Language:JavaScript 100.0%