Search code examples
phpgoogle-analyticsseouniversal-analytics

How to mimic Google Analytics utmz-cookie creation?


Now we are using standard google analytics script dc.js to create utm-cookies by http referrer and http url of the visitor. Now google stops creating utm-cookies since Universal Analytics.

Is there any way to mimic utm-cookie creation logic by referer and url using internal or external solution?

PS. Please, don't advise to get rid of utm-cookies. The main question is: "is it possible to create cookies by the same logic which google does?"


Solution

  • That is not realy easy. You can use the PHP function $_SERVER ['HTTP_REFERER'] but:

    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

    As far as I know, the Universal Analytics HAS a way of tracking referrals using _ga cookies and it works very nice. If you work with PHP (hosted GA), then you will have problems but with JavaScript woks fine.

    If you whant to follow AND _utm cookies with javascript, you need to create some "push" script what will collect that data but I think Universal Analytic have that option automaticly.

    Read THIS blog please.