Im trying to implement Google Analytics in my mvc website. First i tried creating a GA account, unfortunately i'm developing locally on localhost which isn't a valid site URL but i found a fix that will hopefully work here http://www.objectpartners.com/2011/05/26/setting-up-google-analytics-on-localhost/#comment-5960.
Then i copied the generated JS tracking code and paisted it to a view. However i found this article (http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/) about using NuGet package "GoogleAnalyticsTracker" whitch is supposed to let you track your site by using .NET framework. I followed these steps by adding the codeto a controller but the nothing is shown in the view.
I guess one solution would be creating a new GA account, copy the JS tracking code and paiste it into /Views/Shared/_Layout.cshtml.
Has annyone anny experiance implementing Google Analytics in a MVC4 application?
Thank you!
It's really as simple as:
@{ Html.RenderPartial("GoogleAnalytics"); }
in a template which is used by all pagesThis is my organised approach however you can put it in any location as long as the code is visible on every page you want to track.