javascript - Test Google Analytics from localhost -
i've seen this: can test google analytics on localhost address? , getting google analytics see test server followed suggested, nothing works.
what did:
- edited hosts file have several additional domains.
- created virtual hosts on local apache httpd server.
- created account in google analytics, created several "properties" (as in websites belong me) in account.
- wrote testing html page report page view google analytic service.
all listings shown below:
c:/windows/system32/drivers/etc/hosts
127.0.0.1 ad-test # testing ad banners 127.0.0.1 testing.foo.tv # testing ad banners 127.0.0.1 testing.foo-sdk.tv # testing ad banners
the relevant part of httpd.conf
<virtualhost *:80> servername ad-test documentroot d:/cygwin/home/wvxvw/projects/admodule <directory "d:/cygwin/home/wvxvw/projects/admodule"> allowoverride order allow,deny allow require granted </directory> </virtualhost>
(looks same other hosts)
the admodule
directory has following index.html
file:
<html><head></head><body> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-xxxxxxx-3']); _gaq.push(['_setdomainname', 'none']); _gaq.push(['_setallowlinker', true]); _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></body></html>
(there variation uses newer api, i'm not posting shortness)
the document.domain
property in above html page set domain specified in google analytics account settings.
when @ requests sent google analytics service, can see javascript being loaded , gif image, too. can call other api functions w/o errors, nothing gets displayed in dashboard.
update
i on pc in 2 days , here's found on google analytics page:
problem solved...
you can use "real time" -> overview left navigations see live data