asp.net web stats - 谷歌分析

时间:2021-02-04 15:13:55

i want to add tracking to my website. I saw google analytics which seems to track what i need.

我想在我的网站上添加跟踪功能。我看到谷歌分析似乎跟踪我需要的东西。

So do i stick the google analytics snippet in each page, in a master page, just in my default page? what is the best practice here to get the best metrics.

那么我是否在每个页面中,在母版页中,只在我的默认页面中粘贴谷歌分析片段?这里获得最佳指标的最佳做法是什么?

4 个解决方案

#1


The google analytics code snippet has to be on every page you want to track.

Google Analytics分析代码段必须位于您要跟踪的每个页面上。

Easiest is to put the code into the master page(s) if you use them.

最简单的方法是将代码放入母版页中(如果使用它们)。

Otherwise put it on every page, or put it into a user control which you can include on the relevant pages or include it using a server-side include, e.g:

否则将其放在每个页面上,或将其放入用户控件中,您可以将其包含在相关页面上或使用服务器端包含它,例如:

<!-- #include file="file_containing_google_analytics_code.js" -->

#2


It depends on the structure of your site. If you have a small number of Master Pages it makes sense in there, or you could put some code to emit it in a base class that you inherit all your pages (or master pages) from, or if you have a standard footer control that you use on all pages you can put it in there.

这取决于您网站的结构。如果你有少量的母版页在那里是有意义的,或者你可以放一些代码在基类中发出它,你继承了你的所有页面(或母版页),或者如果你有一个标准的页脚控件,你可以在所有页面上使用它。

I generally wrap it in a Placeholder in ASP.Net and have some code the switches it on/off from a web.config setting so it doesn't appear when the site is running in test/UAT/dev machines.

我通常将它包装在ASP.Net中的占位符中,并将一些代码从web.config设置开启/关闭,这样当站点在test / UAT / dev机器上运行时就不会出现。

#3


We use Google Analytics, and have incorporated this into our base page - although our first implementation was done with an HttpModule.

我们使用Google Analytics,并将其合并到我们的基页中 - 尽管我们的第一个实现是使用HttpModule完成的。

I like the base page approach, because it is a common area for some like-minded tasks. It additionally moves the viewstate to the bottom of the form, removes whitespace, etc.

我喜欢基页面方法,因为它是一些志同道合的任务的常见区域。它还将视图状态移动到窗体的底部,删除空格等。

#4


You should take a look here : http://blog.sb2.fr/post/2008/12/21/Google-Analytics-WebControl-for-ASPNET.aspx

你应该看看这里:http://blog.sb2.fr/post/2008/12/21/Google-Analytics-WebControl-for-ASPNET.aspx

#1


The google analytics code snippet has to be on every page you want to track.

Google Analytics分析代码段必须位于您要跟踪的每个页面上。

Easiest is to put the code into the master page(s) if you use them.

最简单的方法是将代码放入母版页中(如果使用它们)。

Otherwise put it on every page, or put it into a user control which you can include on the relevant pages or include it using a server-side include, e.g:

否则将其放在每个页面上,或将其放入用户控件中,您可以将其包含在相关页面上或使用服务器端包含它,例如:

<!-- #include file="file_containing_google_analytics_code.js" -->

#2


It depends on the structure of your site. If you have a small number of Master Pages it makes sense in there, or you could put some code to emit it in a base class that you inherit all your pages (or master pages) from, or if you have a standard footer control that you use on all pages you can put it in there.

这取决于您网站的结构。如果你有少量的母版页在那里是有意义的,或者你可以放一些代码在基类中发出它,你继承了你的所有页面(或母版页),或者如果你有一个标准的页脚控件,你可以在所有页面上使用它。

I generally wrap it in a Placeholder in ASP.Net and have some code the switches it on/off from a web.config setting so it doesn't appear when the site is running in test/UAT/dev machines.

我通常将它包装在ASP.Net中的占位符中,并将一些代码从web.config设置开启/关闭,这样当站点在test / UAT / dev机器上运行时就不会出现。

#3


We use Google Analytics, and have incorporated this into our base page - although our first implementation was done with an HttpModule.

我们使用Google Analytics,并将其合并到我们的基页中 - 尽管我们的第一个实现是使用HttpModule完成的。

I like the base page approach, because it is a common area for some like-minded tasks. It additionally moves the viewstate to the bottom of the form, removes whitespace, etc.

我喜欢基页面方法,因为它是一些志同道合的任务的常见区域。它还将视图状态移动到窗体的底部,删除空格等。

#4


You should take a look here : http://blog.sb2.fr/post/2008/12/21/Google-Analytics-WebControl-for-ASPNET.aspx

你应该看看这里:http://blog.sb2.fr/post/2008/12/21/Google-Analytics-WebControl-for-ASPNET.aspx