Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Convert Google Analytics cookies to Local/Session Storage -


update http://jsfiddle.net/musicisair/rsktp/embedded/result/


google analytics sets 4 cookies sent requests domain (and ofset subdomains). can tell no server uses them directly; they're sent __utm.gif query param.

now, google analytics reads, writes , acts on values , need available ga tracking script.

so, wondering if possible to:

  • rewrite __utm* cookies local storage after ga.js has written them
  • delete them after ga.js has run
  • rewrite cookies local storage cookie form right before ga.js reads them
  • start over

or, monkey patch ga.js use local storage before begins cookie read/write part.

obviously if going far out of way remove __utm* cookies we'll want use async variant of analytics.

i'm guessing down vote because didn't ask question. doh!

my questions are:
can done described above?
if so, why hasn't been done?


i have default html/css/js boilerplate template passes yslow, pagespeed, , chrome's audit near perfect scores. i'm looking way squeeze remaining cookie bytes google analytics in browsers support local storage.

use this:

(function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o), m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');  if(window.localstorage) {     ga('create', 'ua-98765432-1', 'www.example.com', {       'storage': 'none'       , 'clientid': window.localstorage.getitem('ga_clientid')     });     ga(function(tracker) {       window.localstorage.setitem('ga_clientid', tracker.get('clientid'));     }); } else {     ga('create', 'ua-98765432-1', 'www.example.com'); } ga('send', 'pageview'); 

first, check if localstorage supported. if supported 'storage': 'none' option disable cookies. can set clientid localstorage. if empty, google analytics generate new 1 us. save new (or existing) clientid in localstorage after tracker loads.

if localstorage not supported, use regular analytics method. after initialization send pageview via ga('send', 'pageview').

also, check out plunk: http://plnkr.co/mwh6xwgk00u3cfotzepk


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -