html - URL string cannot pass to GA Custom Variables via javascript -
i attempting parse url string custom variable in ga using javascript. string want parsed value after parameter etid=
so example using www.site.com/?etid=1234kks0, variable gets returned should 1234kkso.
the code using seems work in browser console when recall variable name, not return in ga,
function getqueryvariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } var etid = getqueryvariable("etid"); _gaq.push(['_setcustomvar',4,'user',etid,1]);
Comments
Post a Comment