javascript - Track domain from subdomain (Google analytics) -
i've added code on subdomain of domain track pages don't know why doesn't work.
i mention tracked pages on domain, not on subdomain.
<script type="text/javascript"> window.onload = function () { var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-15318659-1']); _gaq.push(['_setdomainname', 'savoyhotel.ro']); var hdstep = parseint(document.getelementbyid('hdstep').value); switch (hdstep) { case 1: { _gaq.push(['_trackpageview', '/alege-data']); if(document.location.hash == '#test-lucian-20130401') { alert('alege-data') } break; } case 2: { _gaq.push(['_trackpageview', '/alege-camera']); if(document.location.hash == '#test-lucian-20130401') { alert('alege-camera') } break; } case 3: { _gaq.push(['_trackpageview', '/date-personale']); if(document.location.hash == '#test-lucian-20130401') { alert('date-personale') } break; } case 4: { _gaq.push(['_trackpageview', '/finalizare-fara-garantare']); if(document.location.hash == '#test-lucian-20130401') { alert('finalizare-fara-garantare') } break; } case 5: { _gaq.push(['_trackpageview', '/finalizare']); if(document.location.hash == '#test-lucian-20130401') { alert('finalizare') } break; } } (function() { var ga = document.createelement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(ga, s); })(); } </script>
anybody have idea?
you need track base domain '.savoyhotel.ro' (notice . @ beginning), , inside analytics set rules filter domains , subdomains. example on of our sites have filters in analytics permit display traffic main domain, sub domain, , combined, while using singular analytics tag.
on ipad right bit of pain elaborate if no 1 posts more detailed answer ill post steps follow in few hours when home pc
but boils down said here setting sub domain include filter in google analytics
update:
1st, switch using normal analytics code, , add . front of domain
<script> var _gaq = _gaq || []; _gaq.push(['_setaccount' , 'ua-15318659-1']); _gaq.push(['_setdomainname', '.savoyhotel.ro']); _gaq.push(['_trackpageview']); (function() { var ga = document.createelement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(ga, s); })(); </script>
now if create little wrapper function facilitate calling trackpageview code whenever need to
function trackpageview(page) { window._gaq = window._gaq || []; window._gaq.push(['_trackpageview', page]); }
this thing need track pageviews main domain + subdomains
now if can setup profiles in analytics have 1 profile shows analytics main domain, , profile subdomains, , thats setting sub domain include filter in google analytics come in.
Comments
Post a Comment