在Mvc4 / C#实现谷歌Analytics(分析)? [英] Implementing Google Analytics in Mvc4/C#?

查看:205
本文介绍了在Mvc4 / C#实现谷歌Analytics(分析)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着去实现我的MVC的网站谷歌分析。首先,我试图创建一个帐户GA,不幸的是我在本地主机本地开发这不是一个有效的网站网址,但我找到了解决,希望能在这里工作的http://www.objectpartners.com/2011/05/26/setting-up-google-analytics-on-localhost/#comment-5960.

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.

然后我复制生成的JS跟踪code和它paisted到一个视图。然而,我发现这篇文章(<一个href=\"http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/\" rel=\"nofollow\">http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/)有关使用的NuGet包GoogleAnalyticsTracker加入WTO要求应该让你通过使用.NET Framework跟踪您的网站。我遵循这些步骤加入codeTO控制器,但没有什么是在视图中显示。

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.

我想一个解决方案是创建一个新帐户GA,复制JS跟踪code和paiste入/Views/Shared/_Layout.cshtml。

I guess one solution would be creating a new GA account, copy the JS tracking code and paiste it into /Views/Shared/_Layout.cshtml.

拥有annyone ANNY的experiance实现谷歌分析在MVC4应用程序?

Has annyone anny experiance implementing Google Analytics in a MVC4 application?

感谢您!

推荐答案

这真的很简单:


  1. 创建一个名为Google分析的局部视图

  2. 复制和放大器;粘贴Analytics(分析)跟踪谷歌的JavaScript code

  3. 使用 @ {Html.RenderPartial这是用于所有页面的模板(Google分析)

  4. 发布网站

  5. 等待24小时的统计数据出现

这是我的有组织的方法,但是你可以把它放在任何位置,只要就像code是可见的,你要跟踪的每一页

This is my organised approach however you can put it in any location just as long as the code is visible on every page you want to track

这篇关于在Mvc4 / C#实现谷歌Analytics(分析)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆